usr bin env python task The sum of the primes below 10 is 17 Find the

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
task = """The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million."""
__doc__ = task
answer = 142913828922
solved = False
approximate_time_to_finish = 60
from euler import atkins_sieve as primes
from euler import print_status, task_main
from operator import truediv, mul
from time import time
def solve(limit=2*10**6, step=10**4, verbose=False):
def verbose():
percentage = step
prime = primes(limit)
while True:
item = prime.next()
yield item
if item > percentage:
percentage += step
print_status("Done already: %s%%" % str(mul(truediv(item, limit), 100))[:5])
if verbose:
return sum(verbose())
else:
return sum(primes(limit))
def main():
task_main(solve)
if __name__ == '__main__':
main()