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.
Maintain a boolean array for very fast primality check sieving for n <= 10^k, then use a fast primality test (e.g.: Miller-Rabin) for n > 10^k. My code passes all tests sieving for either 10^6, 10^7 and 10^8.
If you are already doing that, you need to optimize somewhere else :)
Maintain a boolean array for very fast primality check sieving for n <= 10^k, then use a fast primality test (e.g.: Miller-Rabin) for n > 10^k. My code passes all tests sieving for either 10^6, 10^7 and 10^8.
If you are already doing that, you need to optimize somewhere else :)
Note: there are a few sets producing the same sum, e.g. for 1235679 you get 5+13+29+67 = 5+19+23+67 = 114.
Would you brute force, then test?