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 need a prime test for large numbers. I use Miller-Rabin (like most of us).

add your standard prime sieve (which should be able to generate the first 400000 primes).

Major algorithmic hint:
I was surprised to find that all relevant chains start at very small primes. The first prime number of any chain is <= 131 (!). Knowing this you should be able to easily solve all test cases.

Note: even N=2 is a sum/chain (with only one element, though)

## Project Euler #50: Consecutive prime sum

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

Implementation hints:

Major algorithmic hint: I was surprised to find that all relevant chains start at very small primes. The first prime number of any chain is <= 131 (!). Knowing this you should be able to easily solve all test cases.Note: even N=2 is a sum/chain (with only one element, though)

Is there any way to solve this without considering the fact that all such chains start with a small prime?

Nice hints.