Possible duplicate:
Need help solving Project Euler 200
Similarly this question
Project Euler Problem 200.
I wrote a brute force solution in Java that takes several hours to run, and produced the first 500+ sqube numbers, which I thought should be sufficient. However, none of the answers from 190 to 210 seems to be the correct answer.
I am wondering what I'm doing wrong here and how I can optimize it. Could the problem be BigInteger.isProbablePrime()?
I'm not sure Stackoverflow is the best place to ask about this, but I seem to be stuck. I included my code and the generated data.
I would really appreciate if anyone would give me hints or pointers.
Edit: I ran the program again using the first 500,000 primes; took a day to fulfill, but gave the correct answer.
source
share