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?
The solve this one, we should learn how to check whether a number is prime, can also refer to Problem 3
The whole code is as follows:
import math
def isPrime(data):
i = 2
while i <= math.sqrt(data):
if data%i == 0:
return False
i += 1
return True count = 10001
i = 2
while count > 0:
if isPrime(i):
count -= 1
i += 1
print(i-1)