TITLE: Is there any guarantee of maximum distance to next prime?
QUESTION [5 upvotes]: When watching the Numberphile video about Highly Composite Number, I spotted something that aroused some of my doubts. One of properties suggested by Ramanujan was that the highly composite number's powers of prime factors are in order of decreasing order, with the highest prime factor almost always (with exactly 2 exceptions: 4 and 36.) appearing with power of 1.
It seems to me this assertion hinges upon the next prime after the last being lower than the square of the previous one. While π(N) shows the average distance between the consecutive primes would be significantly lower than between the prime and it's square, as I understand it's more of a probabilistic thing, and while very unlikely, it's not guaranteed next prime will be found within pretty much any finite distance of the prior one. So is this property of highly composite numbers just a conjecture based on dwindling probability of such a gap between primes ever appearing, or is there some solid proof to it?

REPLY [2 votes]: If I understand your question, you are asking if there is a bound on the gaps between primes or if at some point in the primes there could be a huge gap that is way out of the ordinary.
Well, there is a bound from this wikipedia page that gives the following bounds on the nth prime number (for n > 6):
$$\ln(n) + \ln(\ln(n)) - 1 < \frac{p_n}{n} < \ln(n) + \ln(\ln(n))$$
Now let's assume we have $p_n$ and $p_{n+1}$ where $p_n$ is the smallest possible and $p_{n+1}$ is the largest possible.  Then the difference would be:
$$g_n < (n+1)(\ln(\ln(n+1)) + \ln(n+1)) - n(\ln(\ln(n)) + \ln(n) - 1)$$
$g_n$ is the gap between the nth and the n+1 th prime.  If you are willing to be a little less exact you can assume that $\ln(n+1)=\ln(n)$ because as $n \to \infty$, $\ln(n+1)\to\ln(n)$, you get this result:
$$g_n ≲ \ln(\ln(n)) + \ln(n) + n$$
So it seems that it would be impossible for $p_n > p_{n-1}^2$.  There is also something I heard on numberphile which is that there is always a prime between $x$ and $2x$ for any $x$.