Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def eratosthenes(max):
- table = [True for i in range(max)]
- sqrt = math.sqrt(max)
- for i, t in enumerate(table):
- if not t or i == 0 or i == 1:
- continue
- elif i > sqrt:
- break
- for j in range(i*2, max, i):
- table[j] = False
- array = [i for i, j in enumerate(table) if j and i != 1 and i != 0]
- return array
- def sum(array):
- sum = 0
- for val in prime:
- sum += val
- return sum
- prime = eratosthenes(2000000)
- print(sum(prime))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement