zoukankan      html  css  js  c++  java
  • projecteuler---->problem=10----Summation of primes

    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
    


  • 相关阅读:
    UVa 106
    UVa 111
    UVa 105
    UVa 104
    UVa 103
    UVa 102
    UVa 101
    UVa 100
    就决定是你了!
    阿姆斯特朗回旋加速喷气式阿姆斯特朗炮
  • 原文地址:https://www.cnblogs.com/cxchanpin/p/6785213.html
Copyright © 2011-2022 走看看