Project Euler 7 10001st prime
'''
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?
'''
from math import *
def isPrime(num):
if num < 2:
return False
if num == 2:
return True
if num%2 == 0:
return False
i = 3
while( i*i <= num):
if num%i == 0:
return False
i += 2
return True
i=2
s=1
while s<=10001:
if isPrime(i)==True:
s+=1
print i
i+=1
转载于:https://blog.51cto.com/bigbi/1305087