No.7 The 10001st prime number
Q: 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?
A: import math import time
t1 = time.time()
def getNum(n): #for i in range(2,int(n/2)): for i in range(2,int(math.sqrt(n))+1): if n % i == 0: return 0 return n
count = 2 i = 5
while count < 100001: if getNum(i): count += 1 i += 2
print "The 10001st prime number is %d" %(i - 2)
t2 = time.time() print "time used: %s" %(t2 - t1)