# Exists a well-known mathematical formula to locate the umpteenth prime?

Far far better than sieving in the huge array ShreevatsaR recommended (which, for the 10 ¹⁵ th prime, has 10 ¹⁵ participants and also takes around 33 TB to store in portable kind), take an excellent first hunch like Riemann is R and also make use of among the innovative approaches of calculating pi (x) for that first hunch. (If this is away for one reason or another-- it should not be-- approximate the range to the correct factor and also compute a new hunch from there.) Now, you can sieve the tiny range, probably simply 10 ⁸ or 10 ⁹, to the wanted number.

This has to do with 100,000 times much faster for numbers around the dimension I showed. Also for numbers as tiny as 10 to 12 figures, this is much faster if you do not have a precomputed table huge sufficient to have your solution.

There are formulas on Wikipedia, though they are unpleasant. No polynomial $p(x)$ can result the $n$th prime for all $n$, as is clarified in the first area of the write-up.

There is, nonetheless, a polynomial in 26 variables whose *nonnegative * values are specifically the tops. (This is rather pointless regarding calculation is worried.) This originates from the reality that the building of being a prime is decidable, and also the theorem of Matiyasevich.

No, there is no well-known formula that offers the umpteenth prime, other than fabricated ones you can write that are primarily equal to "the $n$th prime". Yet if you just desire an estimate, the $n$th prime is about around $n \ln n$ (or extra specifically, near the number $m$ such that $m/\ln m = n$) by the prime number theorem. Actually, we have the adhering to asymptotic bound on the $n$th prime $p_n$ :

$n \ln n + n(\ln\ln n - 1) < p_n < n \ln n + n \ln \ln n$ for $n\ge{}6$

You can sieve within this array if you desire the $n$th prime. [Edit : There are far better suggestions than a filter, see the solution by Charles. ]

Totally unconnected : if you intend to see solutions that create a great deal of tops (not the $n$th prime) approximately some level, like the renowned $f(n)=n^2-n+41$, consider the Wikipedia write-up formula for primes, or Mathworld for Prime Formulas.

No such formula is recognized, yet there are a couple of that offer remarkable outcomes. A renowned one is Euler's : $$P(n) = n^2 − n + 41$$. Which returns a prime for every single all-natural number less than $41$, though not always the $n$th prime.

See extra here.

Related questions