码迷,mamicode.com
首页 > 编程语言 > 详细

欧拉计划(python) problem 7

时间:2015-01-26 22:47:11      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:

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 :

import math
sqrt=math.sqrt


def func(x):
    k=int(sqrt(x))+1
    for i in range(2,k):
        if x%i==0:
            return 0
    return 1
k=3
temp=6
while 1:
    temp+=1
    if func(temp)==0:
        continue
    else:
        k+=1
        if k==10001:
            break
print(temp)


result : 104743

timt : 1s


欧拉计划(python) problem 7

标签:

原文地址:http://blog.csdn.net/zhangzhengyi03539/article/details/43163713

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!