码迷,mamicode.com
首页 > 其他好文 > 详细

projecteuler---->problem=10----Summation of primes

时间:2017-04-29 16:16:47      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:name   amp   false   title   sum   翻译   begin   time   range   

title:

The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.

Find the sum of all the primes below two million.

翻译:

10下面的质数的和为2 + 3 + 5 + 7 = 17。

请求出200,0000下面全部质数的和。

import math,time
def isOk(a):
	for i in range(2,int(math.sqrt(a))+1):
		if a%i==0:
			return False
	return True
s=0
begin=time.time()
for i in range(2,2000000):
	if isOk(i):
		s += i	
print s
end = time.time()
print end-begin


projecteuler---->problem=10----Summation of primes

标签:name   amp   false   title   sum   翻译   begin   time   range   

原文地址:http://www.cnblogs.com/cxchanpin/p/6785213.html

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