Is it possible that the formula for the $n^{th}$prime number is a polynomial in n?

No, there cannot be any polynomial in $n$ whose value is always the $n$th prime.

Clearly there is no first-degree polynomial with this property. And if the polynomial has degree larger than $1$, then for large $n$ it is going to grow too fast -- such a polynomial would declare too few numbers to be primes, contradicting known facts about how common primes are, in particular the prime number theorem.


By the way, you don't need to raise to the 4th power in your primality test; Wilson's theorem says that $(n-1)!+1$ is divisible by $n$ exactly if $n$ is prime.


In fact there is no non-constant polynomial whose values at the positive integers are all primes.

First, note that any polynomial whose values at the positive integers are primes must have rational coefficients (see e.g. Integer-valued polynomials).

Suppose $P$ is such a polynomial, and let $P(x) = p$ where $p$ is coprime to the denominators of all coefficients of $x$. Then since $(x+p)^k \equiv x^k \mod p$ for all nonnegative integers $k$, we get that $P(x+p) \equiv P(x) \equiv 0\mod p$, so $P(x+p)$ can't be prime.


While Henning Makholm's answer is fantastic, I just feel a little uncomfortable to use so high-tech as the Prime Number Theorem.

Indeed, the reason behind the fact that no polynomial can interpolate the sequence of all primes is that there are too much primes. To be precise, we know that the primes are not an arithmetic sequence, so if a polynomial $q$ were to interpolate them it would need to have degree $\geq2$. This is key because we know that$$\sum_p\frac{1}{p}=+\infty,$$ while if $\deg q\geq2$ then we must have $$\sum_n\frac{1}{q(n)}\leq C\sum_n\frac{1}{n^2}<+\infty$$ for some constant $C$.