We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

You can reduce the size of sieve.By observation,I got that sum of first 126000 primes exceeds 10^12 and for that we need a sieve for 1700000(not exactly).
I think this will help.

Sum of first 126000 primes is 10^11.
( http://wolframalpha.com/input/?i=sum+of+first+126000+primes )
For 10^12 sum you need about 380000 primes and sieve for 6*10^6. Anyway - such sieve (even simple implementation) should be pretty fast (make sure you start marking non-primes with i*i).

## Project Euler #50: Consecutive prime sum

You are viewing a single comment's thread. Return to all comments →

You can reduce the size of sieve.By observation,I got that sum of first 126000 primes exceeds 10^12 and for that we need a sieve for 1700000(not exactly). I think this will help.

Sum of first 126000 primes is 10^11. ( http://wolframalpha.com/input/?i=sum+of+first+126000+primes ) For 10^12 sum you need about 380000 primes and sieve for 6*10^6. Anyway - such sieve (even simple implementation) should be pretty fast (make sure you start marking non-primes with i*i).