Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- # The task: the sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find
- # the sum of all the primes below two million.
- s = set()
- r = 2
- for m in range(2, 1000001):
- for u in range(2 * m, 2000001, m):
- s.add(u)
- for i in range(3, 2000001, 2):
- if not i in s:
- r += i
- print(r)
- # 142913828922
- # 25326301 function calls in 19.818 seconds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement