Project Euler Problem7
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:
1 import math 2 def isPrime(data): 3 i = 2 4 while i <= math.sqrt(data): 5 if data%i == 0: 6 return False 7 i += 1 8 return True 9 10 count = 10001 11 i = 2 12 while count > 0: 13 if isPrime(i): 14 count -= 1 15 i += 1 16 print(i-1)