Skip to main content
4 of 7
added 192 characters in body
rhermans
  • 37.7k
  • 4
  • 64
  • 156

NextPrime has no problems evaluating for large numbers well above $10^{14}$. I think it's safe to assume these are real prime numbers, for confirmation see the answer by @Roman (+1).

You can benchmark the performance of or your analysis using AbsoluteTiming or RepeatedTiming for better statistics.

RepeatedTiming[ NextPrime[ RandomInteger[10^40] ] ,10 ] (* {0.00116824, 7254438951606515242301428266213800581027} *) 

So after evaluating random large numbers repeatedly for 10 seconds, we get an average of 1.117ms per evaluation.

We expect that there will be approximately $n/Log(n)$ prime numbers smaller than $n$ (Prime number theorem), so assuming 1ms per iteration, your calculation will take more than 98 years.

With[ { n = 10^14 }, UnitConvert[ Quantity[1., "Millisecond"] * n/Log[n] ,"Years" ] ] (* Quantity[98.36705486320665, "Years"] *) 

So unless your machine is much faster than mine and you have access to several hundreds of cores, even speeding things up via compilation, I think it may be hard to go over all prime numbers in the range $2$ to $10^{14}$ and do any meaningful tests on them.

enter image description here

rhermans
  • 37.7k
  • 4
  • 64
  • 156