10001st prime

Problem 7

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10 001st prime number?

Ans:-104743

Code:-

def isPrime(n):
if n < 2: return "Neither prime, nor composite"
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True

# returns the nth prime number
def nthPrime(n):
numberOfPrimes = 0
prime = 1

while numberOfPrimes < n:
prime += 1
if isPrime(prime):
numberOfPrimes += 1
return prime

print(nthPrime(10001))

Programming Problem on Hackerrank.com

By listing the first six prime numbers:2,3,5,7,11  and 13 , we can see that the 6th  prime is 13 .
What is the  Nth prime number?

Input Format

First line contains T  that denotes the number of test cases. This is followed by T lines, each containing an integer, N.

Constraints

• 1⩽T⩽ 103
• 1⩽N⩽ 104

Output Format

Print the required answer for each test case.

Sample Input

2
3
6

Sample Output

5
13

Explanation 0

The first 10  prime numbers are

{2,3,5,7,11,13,17,19,23,29}

we can see that 3rd prime number is 5 and 6th prime number is 13

Code:-
import math

def prime(n,l):
x=l[len(l)-1]
while len(l)y:
count=0
break
if x%i==0:
count=1
break
if count==0:
l.append(x)
return l

t=int(input())
l=[2,3]
for i in range(t):
n=int(input())
if len(l)