# Thread: Average succesive distances between primes below n, graphed

1. ## Average succesive distances between primes below n, graphed

I wrote a computer program function that takes an integer as input and outputs the average distance between all the succesive primes below this integer. I graphed the data and ran a logarithmic regression on it and came up with the green curve seen in the attached image. Would this regularity be something expected of a graph like this? Its just an interesting property, to me.

2. Originally Posted by mfetch22
I wrote a computer program function that takes an integer as input and outputs the average distance between all the succesive primes below this integer. I graphed the data and ran a logarithmic regression on it and came up with the green curve seen in the attached image. Would this regularity be something expected of a graph like this? Its just an interesting property, to me.
The prime number theorem tells us $\displaystyle \pi(x)\sim\frac{x}{\log x}$.

This can be manipulated to show $\displaystyle p_n\sim n\log n$, where $\displaystyle p_n$ is the $\displaystyle n^{th}$ prime.

So loosely speaking, $\displaystyle S(n)=\frac{1}{\pi(n)}\sum_{i=2}^{\pi(n)} (p_i-p_{i-1})=\frac{p_{\pi(n)}-2}{\pi(n)}$ $\displaystyle \sim \frac{\pi(n)\log \pi(n)}{\pi(n)}=\log \pi(n) \sim \log n-\log\log n \sim \log n$ since the sum is telescoping.