Project Euler #50: Consecutive prime sum

  • + 2 comments

    Implementation hints:

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