Is there any guarantee of maximum distance to next prime? 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?
 A: 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$.
A: We can do even better than finding a prime smaller than the square of the previous: Bertrand's postulate, or the Bertrand-Chebyshev theorem, tells us that there is always a prime between $n$ and $2n$.
As a side note, the distribution of the primes is not at all "a probabilistic thing". Every statement about prime numbers, in specific ranges, or based on variables, etc. is either true or false, though it may be very difficult or impossible to prove or disprove some such statements. The prime number theorem and many similar results tell us some things which are always true as patterns in the limit when we take averages of large ranges. Since this is similar to some patterns in random variables which are almost always true when we take averages of many samples, some of the same techniques for dealing with random variables can be applied in much the same ways to properties of the prime numbers. But these arguments can only tell us about average properties for large numbers, and don't always help attempting to show something always or never happens, or applies in any way to small numbers.
