I want to find the first 5 prime numbers of the form n^6 + 1091$n^6 + 1091$. I have used this code:
Timing[Select[Table[n^6 + 1091, {n, 10000}], PrimeQ, 5]] Which gives the desired answer, and takes 0.0156 seconds. What if I didn't have a rough idea of what values of n$n$ to check?
Timing[Select[Table[n^6 + 1091, {n, 100000}], PrimeQ, 5]] Takes 10 times as long.
So, my question is: Is there a simple(ish) way to make MathematicaMathematica stop when the desired number of solutions are found?