# Project Euler #50: Consecutive prime sum

# Project Euler #50: Consecutive prime sum

stbrumme + 2 comments Implementation hints:

- 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)

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

linyu203 + 0 comments Nice hints.

armogur + 0 comments just for the record: under 100 million there are only 1392 records exists

avvari_pavan9 + 0 comments anybody have solution in java

andres_jaanson + 0 comments At first I felt this task is really difficult, almost unsolvable but once I found the longest possible chain starting with 2 and which is prime and less then or equal to 10**12. Then I realized this task is not that hard.

So if you feel stuck or just have no ideas. Then build an algorithm which finds the result mentioned before and I believe you will know how to continue.

vish_14 + 1 comment sum([7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89])=953 sum([23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) = 983 983 is also a prime number, then why the ans is 953 not 983?

kedavamaru + 0 comments The first sum has a longer chain of primes, the problem ask for the longest chain, not for the largest sum

Sort 25 Discussions, By:

Please Login in order to post a comment