进阶之路

导航

Problem 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?

 

max1 = 10001
a = [2]
i = 3
while len(a) < max1:
    flag = 0
    for j in a:
        if j > i**0.5: 
            break
        if i%j == 0:
            flag = 1
            break
    if flag == 0:
        a.append(i)
    i+=2

print(a[-1])
        

 

posted on 2018-04-27 11:09  中年小Q  阅读(120)  评论(0编辑  收藏  举报