Intereting Posts

Measurability of the inverse of a measurable function
Theorem 6.15 in Baby Rudin: If $a<s<b$, $f$ is bounded on $$, $f$ is continuous at $s$, and $\alpha(x)=I(x-s)$, then . . .
Prove that $(a+1)(a+2)…(a+b)$ is divisible by $b!$
Positive integer multiples of an irrational mod 1 are dense
Normal at every localization implies normal
6/2*(1+2) is 1 or 9?
Let $(s_n)$ be a sequence of nonnegative numbers, and $\sigma_n=\frac{1}{n}(s_1+s_2+\cdots +s_n)$. Show that $\liminf s_n \le \liminf \sigma_n$.
Classify sphere bundles over a sphere
Understanding limsup
What is the difference between “family” and “set”?
Heisenberg uncertainty principle in $d$ dimensions.
Help proving exercise on sequences in Bartle's Elements
How to solve this nonlinear constrained optimization problem
Maximize area of a rectangle
Why is $\int^\infty_{-\infty} \frac{x}{x^2+1} dx$ not zero?

I’ve solved for it making a computer program, but was wondering there was a mathematical equation that you could use to solve for the nth prime?

- a new continued fraction for $\sqrt{2}$
- Why is Peano arithmetic undecidable?
- Unique Decomposition of Primes in Sums Of Higher Powers than $2$
- Extension $\mathbb{Q}(\sqrt{-5}, i)/\mathbb{Q}(\sqrt{-5})$, splitting.
- Proof of binomial coefficient formula.
- How find this $xyz|(xy-1)(xz-1)(yz-1)$
- Proof of infinitude of primes using the irrationality of π
- Find all $x,y\in \mathbb{N}$ such that: $2^x+17=y^2$.
- Chicken Mcnugget Theorem (Frobenous Coin) Problem
- Variation of Pythagorean triplets: $x^2+y^2 = z^3$

No, there is no known formula that gives the nth prime, except artificial ones you can write that are basically equivalent to “the $n$th prime”. But if you only want an approximation, the $n$th prime is roughly around $n \ln n$ (or more precisely, near the number $m$ such that $m/\ln m = n$) by the prime number theorem. In fact, we have the following 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 range if you want the $n$th prime. [Edit: There are better ideas than a sieve, see the answer by Charles.]

Entirely unrelated: if you want to see formulae that generate a lot of primes (not the $n$th prime) up to some extent, like the famous $f(n)=n^2-n+41$, look at the Wikipedia article formula for primes, or Mathworld for Prime Formulas.

There are formulas on Wikipedia, though they are messy. No polynomial $p(x)$ can output the $n$th prime for all $n$, as is explained in the first section of the article.

There is, however, a polynomial in 26 variables whose *nonnegative* values are precisely the primes. (This is fairly useless as far as computation is concerned.) This comes from the fact that the property of being a prime is decidable, and the theorem of Matiyasevich.

Far better than sieving in the large range ShreevatsaR suggested (which, for the 10^15-th prime, has 10^15 members and takes about 33 TB to store in compact form), take a good first guess like Riemann’s R and use one of the advanced methods of computing pi(x) for that first guess. (If this is far off for some reason — it shouldn’t be — estimate the distance to the proper point and calculate a new guess from there.) At this point you can sieve the small distance, perhaps just 10^8 or 10^9, to the desired number.

This is about 100,000 times faster for numbers around the size I indicated. Even for numbers as small as 10 to 12 digits this is faster if you don’t have a precomputed table large enough to contain your answer.

No such formula is known, but there are a few that give impressive results. A famous one is Euler’s:

$$P(n) = n^2 − n + 41$$

Which yields a prime for every natural number lower than $41$, though not necessarily the $n$th prime.

See more here.

- History of Modern Mathematics Available on the Internet
- Convolution of half-circle with inverse
- Proof of fundamental lemma of calculus of variation.
- Prove that $\sum\limits_{n=0}^{\infty}{(e^{b_n}-1)}$ converges, given that $\sum\limits_{n=0}^{\infty}{b_n}$ converges absolutely.
- how to define the composition of two dominant rational maps?
- Convergence of $\sqrt{n}x_{n}$ where $x_{n+1} = \sin(x_{n})$
- Question on the fill-in morphism in a triangulated category
- Is $f$ measurable with respect to the completion of the product $\sigma$-algebra $\mathcal{A} \times \mathcal{A}$ on $^2$?
- Derangements of multisets
- Proving :$\frac{1}{2ab^2+1}+\frac{1}{2bc^2+1}+\frac{1}{2ca^2+1}\ge1$
- Rapid approximation of $\tanh(x)$
- Decomposition Theorem for Posets
- Confused about complex numbers
- Minimal polynomial and invariant subspaces.
- Converse to Hilbert basis theorem