You are viewing a single comment's thread. Return to all comments →
I create sieve for 6000000, use the Miller-Rabin for above, but still need about 15 sec in JAVA.
If I limit my table for about max 100000 consecutive sums, then no timeout, but it's good only for the first 7 testcases.
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).