Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer
I believe community wiki abuse is mentioned as a scientific perversion somewhere in the Marquis de Sade complete works. – Dr. belisarius May 24 '13 at 20:21
@bel, I would have left it as a comment, but it was too damn long. :P – J. M. May 25 '13 at 1:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.