Possible Duplicate:
Need help solving Project Euler problem 200
Similar to this question
I wrote up a brute force solution in Java that takes several hours to run, and produced the first 500+ sqube numbers, which I thought should be enough. However, none of the answers from 190 to 210 seems to be the correct answer.
I’m wondering what I’m doing wrong here and how I could optimize this. Could the problem lie in BigInteger.isProbablePrime()?
I’m not sure if Stackoverflow is the best place to ask this, but I seem to be stuck. I’ve included my code and the generated data.
I’d really appreciate it if someone would give me some hints or pointers.
Edit: I’ve run the program again simply with using the first 500,000 prime numbers; took a day to run but produced the correct answer.
I’m a Project Euler administrator. Please do not post information that can spoil the problem for others, particularly code and answers, even half-functioning code. Please edit your question accordingly. EDIT: Thank you for doing so!
It’s not unusual for solvers to use the web to search for information on solving a problem, and it would take away some fun if they stumbled upon such a spoiler. (Yes, I know there are sites with lots of solutions ready-made, but at least they’re generally for the lowered numbered easy problems.)
We have forums for discussing difficulties with problems and getting hints, which are aggressively edited for spoilers.