A prime gap is the difference between two successive prime numbers. The n-th prime gap, denoted gn or g(pn) is the difference between the (n + 1)-th and the n-th prime numbers, i.e.
We have g1 = 1, g2 = g3 = 2, and g4 = 4. The sequence (gn) of prime gaps has been extensively studied, however many questions and conjectures remain unanswered.
The first 60 prime gaps are:
By the definition of gn every prime can be written as
The first, smallest, and only odd prime gap is 1 between the only even prime number, 2, and the first odd prime, 3. All other prime gaps are even. There is only one pair of gaps between three consecutive odd natural numbers for which all are prime. These gaps are g2 and g3 between the primes 3, 5, and 7.
For any prime number P, we write P# for P primorial, that is, the product of all prime numbers up to and including P. If Q is the prime number following P, then the sequence
is a sequence of Q − 2 consecutive composite integers, so here there is a prime gap of at least length Q − 1. Therefore, there exist gaps between primes that are arbitrarily large, i.e., for any prime number P, there is an integer n with gn ≥ P. (This is seen by choosing n so that pn is the greatest prime number less than P# + 2.) Another way to see that arbitrarily large prime gaps must exist is the fact that the density of primes approaches zero, according to the prime number theorem. In fact, by this theorem, P# is very roughly a number the size of exp(P), and near exp(P) the average distance between consecutive primes is P.
In reality, prime gaps of P numbers can occur at numbers much smaller than P#. For instance, the smallest sequence of 71 consecutive composite numbers occurs between 31398 and 31468, whereas 71# has twenty-seven digits – its full decimal expansion being 557940830126698960967415390.
Although the average gap between primes increases as the natural logarithm of the integer, the ratio of the prime gap to the integers involved decreases (and is asymptotically zero). This is a consequence of the prime number theorem; see below. On the other hand, the ratio of the gap to the number of digits of the integers involved does increase without bound. This is a consequence of a result by Westzynthius; see below.