I had asked this question in [MSE](https://math.stackexchange.com/questions/2921560/is-this-riemann-integral-for-prime-numbers-true). It got lot of upvotes but no answer (except one which was too long to be posted as a comment) hence I am posting it in MO.


While answering another [question in MSE](https://math.stackexchange.com/questions/2917887/do-arithmetic-mean-and-geometric-mean-of-prime-numbers-converge/2919825#2919825) I had used the following result which I thought was a trivial consequence of the prime number theorem and equidistribution. However, I realized from the comments that many people thought that this was not either true or counter intuitive. Hence I am posting this as a question looking for a proof or disproof.



> 
> Let $p\_k$ be the $k$-th prime and $f$ be a continuous function
>  Riemann integrable in $(0,1)$ such that 
> 
> 
> $$\lim\_{n \to \infty}\frac{1}{n}\sum\_{r = 1}^{n}f\Big(\frac{r}{n}\Big)
> = \int\_{0}^{1}f(x)dx. $$ 
> 
> 
> Then, $$ \lim\_{n \to \infty}\frac{1}{n}\sum\_{r =
> 1}^{n}f\Big(\frac{p\_r}{p\_n}\Big) = \int\_{0}^{1}f(x)dx. $$
> 
> 
> 


**My approach**: It was was based on showing that as $n \to \infty$, the ratios $p\_r/p\_n$ approached equidistribution in $(0,1)$ hence the integral follows as a property of equidistributed sequence.


**Motivation**: There are several identities, limits etc on prime numbers which can be easily proven using this simple formula. 



Riemann sum formula for definite integral using prime numbers
The statement follows from the prime number theorem. By an approximation argument, we can assume that $f$ is continuously differentiable on $[0,1]$. Then,
$$\sum\_{r=1}^{n}f\left(\frac{p\_r}{p\_n}\right)=\int\_0^1 f(x)\,d\pi(p\_n x)=nf(1)-\int\_0^1 f'(x)\pi(p\_n x)\,dx.$$
We estimate the last integral for fixed $f$:
$$\int\_0^1 f'(x)\pi(p\_n x)\,dx=\int\_{\frac{1}{\log n}}^1 f'(x)\pi(p\_n x)\,dx+o(n).$$
In the last integral, we have by the prime number theorem,
$$\pi(p\_n x)\sim\frac{p\_n x}{\log(p\_n x)}\sim\frac{p\_n x}{\log n}\sim nx,$$
so that
\begin{align\*}\int\_0^1 f'(x)\pi(p\_n x)\,dx
&=\int\_{\frac{1}{\log n}}^1 f'(x)\bigl(nx+o(nx)\bigr)\,dx+o(n)\\
&=\int\_{0}^1 f'(x)\bigl(nx+o(nx)\bigr)\,dx+o(n)\\
&=n\int\_0^1 f'(x)x\,dx+o(n)\\
&=nf(1)-n\int\_0^1 f(x)\,dx + o(n).
\end{align\*}
Putting everything together,
$$\sum\_{r=1}^{n}f\left(\frac{p\_r}{p\_n}\right)=n\int\_0^1 f(x)\,dx + o(n),$$
that is,
$$\frac{1}{n}\sum\_{r=1}^{n}f\left(\frac{p\_r}{p\_n}\right)=\int\_0^1 f(x)\,dx + o(1).$$


