标签:style blog class code java color
是我算法不对,还是笔记本CPU太差?
我优化了两次,还是花了三四个小时来得到结果。
在输出上加1就是最终结果。
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
def isprime(n): boolisprime = True for i in xrange(3,n): if n % i == 0: boolisprime = False break return boolisprime def primenumber(n): i = 1 sumprime = 0 while True: if isprime(i) == True: sumprime += i print i,sumprime if i > n: break i += 2 return sumprime print primenumber(2000000)+1
Summation of primes,布布扣,bubuko.com
标签:style blog class code java color
原文地址:http://www.cnblogs.com/aguncn/p/3718137.html