Friday, September 6, 2024

Number of primes between n and 2n?

Chebyshev said it, but I'll say it again; There's always a prime between n and 2n.

But how many primes there are between n and 2n?


The prime number theorem (PNT) says that π(n) ~ n/ln(n).


So, the number of primes between n and 2n is roughly π(2n)- π(n) ≈ 2n/ln(2n) - n/ln(n).


Now, ln(2n) = ln(2) + ln(n) which is dominated by ln(n) when n is large.


Hence, we obtain π(2n)- π(n) ≈ 2n/ln(n) - n/ln(n) = (2n-n)/ln(n) = n/ln(n).


Of course, a much better approximation is given by the logarithmic integral 


And here is the plot: