fork download
  1. # sum of the primes less than n
  2.  
  3. def sumPrimes(n):
  4. sum, sieve = 0, [True] * (n+1)
  5. for p in range(2, n):
  6. if sieve[p]:
  7. sum += p
  8. for i in range(p*p, n, p):
  9. sieve[i] = False
  10. return sum
  11.  
  12. print sumPrimes(2000000)
Success #stdin #stdout 1.28s 8848KB
stdin
Standard input is empty
stdout
142913828922