Project Euler Problem 10: Summation Of Primes

The source code for this problem can be found here.

Problem 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 Discussion

Simply accumulate the sum of primes up to the limit. Iterating over primes is off-loaded to lib.sequence.

Solution Implementation

from lib.sequence import Primes

def solve():
    """ Compute the answer to Project Euler's problem #10 """
    target = 2000000
    answer = sum(Primes(upper_bound=target))
    return answer

expected_answer = 142913828922

Compute the answer to Project Euler’s problem #10