Enumeration of primes Given a prime number $p$, there is an associated number $n(p)$, giving its ranking in the sense that $n(2)=1$, $n(3)=2$, $n(5)=3$ etc. Is there a closed form expression for $n(p)$ in terms of $p$?
 A: Well I don't think there is any "nice" closed form in the sense that you can evaluate it easily in term of standard functions. But you can write :
$$
n(p) = \pi(p)
$$
Where $\pi(n)$ is the Prime-counting function
(Note that we have the famous result $x/ln(x) \sim \pi(x)$ )
A: Here is something that I have established a long time ago.
It illustrates the fact that one can easily establish such formula.
The real challenge is to establish a formula which is not "computationally worthless".

First, here is a formula which determines whether or not $x$ is prime:
$$f(x)=\left\lfloor\frac{\left(\sum\limits_{k=2}^{x-1}\left\lceil\frac{{x}\bmod{k}}{x}\right\rceil\right)+2\cdot\left\lceil\frac{x-1}{x}\right\rceil}{x}\right\rfloor$$

Second, here is a formula which counts the number of primes $\leq x$:
$$g(x)=\sum\limits_{k=2}^{x}f(k)$$

Finally, here is the complete formula:
$$n(p)=\sum\limits_{x=2}^{p}\left\lfloor\frac{\left(\sum\limits_{k=2}^{x-1}\left\lceil\frac{{x}\bmod{k}}{x}\right\rceil\right)+2\cdot\left\lceil\frac{x-1}{x}\right\rceil}{x}\right\rfloor$$
