Is there a one-to-one function from the natural numbers to the primes?

Have you heard of Mills' constant? The function defined below, with $A$ being Mills' constant, always gives a prime:

$$f(n)=\left\lfloor A^{3^n}\right\rfloor$$


Coming from theoretical computer science, I'd formalize your question as

Is there a bijection $f: \mathbb{N} \to P$ so that $f(n)$ can be computed in time polynomial in $\lceil \log_2 n\rceil$ (the number of bits of $n$)?

This is a standard way to formulate such "explicit indexing" questions. The requirement that $f$ be efficiently computable is a strong version of requiring that $f$ is "explicit". It also excludes things like computing all the primes up to $n$.

The question stated above is certainly open! The closest result I know to it is a recent paper that shows how to explicitly index irreducible polynomials of a given degree in a finite field. Such polynomials are the "primes" in the ring of polynomials but have much more structure than the primes in the ring of integers.


Here is something that I have established a long time ago.

The answer to your question is $P_n$, but please note that it is "computationally worthless".


Is $n$ prime:

$$F_n=\left\lfloor\frac{\left(\sum\limits_{k=2}^{n-1}\left\lceil\frac{{n}\bmod{k}}{n}\right\rceil\right)+2\cdot\left\lceil\frac{n-1}{n}\right\rceil}{n}\right\rfloor$$


How many primes until $n$:

$$G_n=\sum\limits_{k=2}^{n}F_k$$


What is the $n$th prime number:

$$P_n=\sum\limits_{k=n}^{n^2+1}{k}\cdot{F_k}\cdot\left(1-\left\lceil\frac{(G_k-n)^2}{(G_k+n)^2}\right\rceil\right)$$