Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. 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

$2$ is the first prime number.

$3$ is the second.

If I give a prime number such as $1151024046313875220631$, is there any software/website which can give the position of the prime number?

I know there are resources to find $N$th prime. But I am having a hard time finding the reverse.

share|cite|improve this question
You can always use binary search. – Aryabhata Aug 17 '10 at 16:09
Sieving is more or less what Mathematica does, using the logarithmic integral as an (over)estimate. – J. M. Aug 17 '10 at 16:23
Your number (~10^21) is probably too big for that. – starblue Aug 17 '10 at 19:21
I don't think there is online resource to find the ($2.4\times10^{19}$)th prime. – kennytm Aug 18 '10 at 7:57
up vote 2 down vote accepted

If you have access to Mathematica, PrimePi[x] will give you the number of primes less than x. Combined with PrimeQ, which verifies that x is indeed prime, will give you which prime number x is.

EDIT: I have no idea how long Mathematica would take (or if it could in fact compute it) for a number that high.

share|cite|improve this answer
Mathematica has a built-in ceiling for both Prime[] and PrimePi[]; see the documentation for the error message PrimePi::largp. This is probably both version and machine dependent. – J. M. Aug 17 '10 at 16:20
thanks for the tip – endrendum Aug 23 '10 at 18:48
That number is too big for even the 64-bit version of Mathematica 7. – Charles Sep 8 '10 at 20:30

You can use the function prime_pi in Sage (, which is also available for free online at For example,

   sage: prime_pi(2011)

Like Mathematica, Sage's prime_pi function is too slow to solve your problem above. It's also somewhat slower than Mathematica's still.

share|cite|improve this answer

What you are looking for is the "Prime Counting Function". The closest thing to it you will find online is Wolfram Alpha:

share|cite|improve this answer

If an approximation suffices, you could use the offset logarithmic integral function.

share|cite|improve this answer

Andrew Booker's Nth prime page is excellent... but it can't handle your example number.

I have custom code that can calculate values up to about 2^64, but your number is larger than that.

Thanks to Dusart [1], we can say that its rank is somewhere between 24244547260299402427 and 24247918127257270377.

If the Riemann Hypothesis is true, then we know by Schoenfeld [2] that its rank is somewhere between 24245911027060346607 and 24245911157987206331.

[1] Pierre Dusart, 'Estimates of Some Functions Over Primes without R.H.', preprint (2010), arXiv:1002.0442

[2] Lowell Schoenfeld, 'Sharper Bounds for the Chebyshev Functions theta(x) and psi(x). II'. Mathematics of Computation, Vol 30, No 134 (Apr 1976), pp. 337-360.

share|cite|improve this answer

For primes smaller than your example you can use Wolfram|Alpha, as Adam S pointed out. Wolfram|Alpha has the prime Pi function:

share|cite|improve this answer

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.