Mansi is fond of solving mental ability questions. Today while solving some questions she came across a series which she was unable to solve. Help her to find the nth term of the series.
n  nth term
1  3
2  8
3  18
4  32
5  60
.
.
.
10  300
Example 1:
Input: n = 1
Output: 3 
Explanation: The first term of the series is 3.
Example 2:
Input: n = 2
Output: 8
Explanation: The second term of the series is 3. 
Your Task:  
You dont need to read input or print anything. Complete the function nthTerm() which takes n as input parameter and returns the nth term of the series.
Expected Time Complexity: O(nlogn)
Expected Auxiliary Space: O(n)
Constraints:
1<= n <=6000

Difficulty: EASY
Tags: Number theory

Mathematics
Expected Time Complexity: O(nlogn)
Expected Auxiliary Space: O(n)

Starter code:
#User function Template for python3
class Solution:
    def nthTerm (self, n):
        # code here 

Solutions:
import math

class Solution:

	def isPrime(self, n):
		if n == 0 or n == 1:
			return False
		else:
			lim = int(math.sqrt(n)) + 1
			for i in range(2, lim):
				if n % i == 0:
					return False
			return True

	def nthTerm(self, n):
		(c, prev) = (0, 0)
		for i in range(2, int(100000.0)):
			if self.isPrime(i):
				prev = i
				c += 1
			if c == n:
				return prev * n + n


class Solution:

	def nthTerm(self, n):

		def isPrime(n):
			k = int(n ** 0.5) + 1
			for i in range(3, k, 2):
				if not n % i:
					return False
			return True

		def nthPrime(n):
			if n < 3:
				return n + 1
			(p, i) = (5, 3)
			if n == 3:
				return p
			while i < n:
				p += (p + 3) % 6
				if isPrime(p):
					i += 1
			return p
		return n * (1 + nthPrime(n))


class Solution:

	def nthTerm(self, n):

		def sieve(n):
			primes = [True] * (n + 1)
			for i in range(2, n + 1):
				if primes[i]:
					for j in range(i * i, n + 1, i):
						primes[j] = False
			lst = [i for i in range(2, n + 1) if primes[i]]
			return lst
		primes = sieve(60000)
		return primes[n - 1] * n + n


class Solution:

	def nthTerm(self, n):

		def isPrime(num):
			if num < 2:
				return 0
			for i in range(2, int(num ** 0.5) + 1):
				if num % i == 0:
					return 0
			return 1
		i = 0
		j = 2
		ans = 0
		while i < n:
			if isPrime(j) == 1:
				ans = j
				i += 1
			j += 1
		return (ans + 1) * n


import math

class Solution:

	def isPrime(self, i):
		j = 2
		while j * j <= i:
			if i % j == 0:
				return False
			j += 1
		return True

	def nthTerm(self, n):
		i = 0
		check = 2
		while i < n:
			if self.isPrime(check):
				ans = check
				i += 1
			check += 1
		return (ans + 1) * n


class Solution:

	def nthTerm(self, n):
		a = n * 10
		c = [True] * (a + 1)
		p = 2
		while p * p <= a:
			if c[p] == True:
				for i in range(p * p, a + 1, p):
					c[i] = False
			p = p + 1
		z = 0
		d = []
		for i in range(2, len(c)):
			if c[i] == True:
				z += 1
				d.append(i)
				if z == n:
					return (i + 1) * n


class Solution:

	def nthTerm(self, n):
		x = 10 ** 5
		li = list()
		prime = [True for i in range(x + 1)]
		p = 2
		while p * p <= x:
			if prime[p] == True:
				for i in range(p * p, x + 1, p):
					prime[i] = False
			p += 1
		for p in range(2, x + 1):
			if prime[p]:
				li.append(p)
		ans = (li[n - 1] + 1) * n
		return ans