4

When I enter Prime[2000000000000], the two-trillionth prime, Mathematica gives 61427839512211 for the answer after several minutes of calculation.

I wonder how it calculates to get this number. Apparently, it does not pull that number out from a list, since it spends several minutes to get the answer.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
TCL
  • 149
  • 3

1 Answers1

6

From Some Notes On Internal Implementation:

Prime and PrimePi use sparse caching and sieving. For large $n$, the Lagarias-Miller-Odlyzko algorithm for PrimePi is used, based on asymptotic estimates of the density of primes, and is inverted to give Prime.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574