EularProject 7: 计算10001个素数

来源:互联网 发布:seo关键词优化软件 编辑:程序博客网 时间:2024/06/05 11:28

10001st prime

Problem 7

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?


python code :

<span style="font-family:Times New Roman;font-size:18px;">import mathsqrt=math.sqrtdef func(x):    k=int(sqrt(x))+1    for i in range(2,k):        if x%i==0:            return False    return Truek=3temp=6while 1:    temp+=1    if func(temp):        k+=1        if k==10001:            breakprint(temp)</span>


result : 104743

timt : 1s

------------------
祝身体健康,万事如意

华电北风吹

天津大学计算机科学与技术学院

天津市卫津路92号

邮编: 300072

邮箱: 1194603539@qq.com

1 0