You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
396 B
23 lines
396 B
9 years ago
|
import math
|
||
|
# find the 10001st prime number
|
||
|
|
||
|
def isPrime(number):
|
||
|
prime = True
|
||
|
i = 2
|
||
|
while i < math.sqrt(number) + 1:
|
||
|
if number % i == 0:
|
||
|
prime = False # found a factor, not prime
|
||
|
break
|
||
|
else:
|
||
|
i += 1
|
||
|
|
||
|
return prime
|
||
|
|
||
|
i = 1;
|
||
|
primeCount = 1
|
||
|
while (primeCount != 10001):
|
||
|
if isPrime(i):
|
||
|
primeCount += 1
|
||
|
i += 1
|
||
|
|
||
|
print(i)
|