Project Euler Problem 010

# Statement

The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.

Find the sum of all the primes below two million.

# Solution

In this case I use the Sieve of Eratosthenes to find the prime numbers

summing them up in the process.

if __name__ == '__main__': result = 0 lst = list(range(2, 2000000)) for i in range(0, len(lst)): interval = lst[i] if (interval != -1): result += interval j = i + interval while j < len(lst): lst[j] = -1 j += interval print("The result is:", result)

The Python file is available for download here.