Skip to content

PE 0010: Summation of Primes ​

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

Find the sum of all the primes below two million.


Generating Primes ​

See the discussion on primes TODO: link for generating the sequence of prime integers. There really aren't any tricks here that I'm aware of other than approximating it with the totient function (ok, I can write a bit about that). We could sum on our way up while building the sieve (actually, was thinking of adding some callbacks into the prime utilities in golang).

Exercises ​

  1. What is the largest prime that can fit into a 64-bit integer?

  2. What is the largest sum of primes that can fit into a 64-bit integer?

  3. What are the trade-offs when deciding between big-integer or int64/uint64 for prime factorization and prime sequence generation?