10001st prime
Problem 7
Published on Friday, 28th December 2001, 06:00 pm; Solved by 257306; Difficulty rating: 5%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?
本来想用最笨的方法,从小到大一个一个算,后来看到素筛法,就随便写了些,还是感觉,如果数量再大,这个方法也不好用
upper = 200010
listprime = [True] * (upper+1)
for i in range(2,upper+1):
if listprime[i] == True:
temp = i * 2
while temp < upper:
listprime[temp] = False
temp += i
count = 0
i = 2
while count < 10001 and i < upper:
if listprime[i] == True:
count += 1
i += 1
print(i-1)
print(count)