
A prime gap is the difference between two consecutive prime numbers. If one prime comes right after another in the ordered list of primes, the distance between them is called their prime gap.
For example, 11 and 13 are consecutive primes, so the prime gap is 2. The next prime after 13 is 17, so the gap between 13 and 17 is 4. Prime gaps show that prime numbers do not appear in a fixed rhythm. Sometimes they are close together. Sometimes there is a long stretch with no primes at all.
Quick answer: A prime gap is calculated as next prime − current prime. For consecutive primes p and q, the prime gap is q − p.
What Is a Prime Gap?
Prime numbers are whole numbers greater than 1 that have exactly two positive divisors: 1 and themselves. The primes begin like this:
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31…
A prime gap measures the space between one prime and the next prime in this list. The primes must be consecutive. That means there is no other prime number between them.
In mathematical notation, if pn is the nth prime number, then the gap after it is often written as:
gn = pn+1 − pn
This simply means: take the next prime and subtract the current prime.
Prime Gap Examples
Small prime gaps are easy to see because the first few primes are close together. The pattern becomes less predictable as numbers grow.
| Current prime | Next prime | Prime gap | Calculation |
|---|---|---|---|
| 2 | 3 | 1 | 3 − 2 = 1 |
| 3 | 5 | 2 | 5 − 3 = 2 |
| 7 | 11 | 4 | 11 − 7 = 4 |
| 13 | 17 | 4 | 17 − 13 = 4 |
| 23 | 29 | 6 | 29 − 23 = 6 |
| 89 | 97 | 8 | 97 − 89 = 8 |
The gap from 2 to 3 is the only prime gap equal to 1. After that, every prime except 2 is odd. Since the difference between two odd numbers is even, every prime gap after 2 is even.
Why Prime Gaps Matter
Prime gaps matter because they reveal how primes are spaced across the number line. Prime numbers are not placed randomly in a simple sense, but they also do not follow a repeating pattern that lets us predict every next prime with ease.
A gap gives more information than a yes-or-no prime test. It helps answer a different question: how far do we need to move before we meet the next prime?
This connects prime gaps to several important ideas in number theory:
- Prime density: how common primes are near a certain size.
- Twin primes: pairs of primes separated by a gap of 2.
- Prime deserts: long stretches of composite numbers with no primes.
- Record prime gaps: the largest known gaps found up to a given point.
- Prime distribution: the study of how primes spread out among whole numbers.
Why Are Most Prime Gaps Even?
The reason is simple but important. Apart from 2, every prime number is odd. If a number greater than 2 were even, it would be divisible by 2 and therefore not prime.
So after the first pair 2 and 3, prime gaps compare one odd prime with the next odd prime. The difference between two odd numbers is always even.
Example: 17 and 19 are both odd. Their gap is 2. 23 and 29 are also odd. Their gap is 6. Both gaps are even.
This does not mean every even number appears as a prime gap near the start of the prime list. It only means prime gaps after 2 must be even.
Small Prime Gaps
A small prime gap means two consecutive primes are close together. The most famous small gap is 2, which creates a pair of twin primes.
Gap of 2: Twin Primes
Two primes with a gap of 2 are called twin primes. Examples include:
- 3 and 5
- 5 and 7
- 11 and 13
- 17 and 19
- 29 and 31
The twin prime question asks whether there are infinitely many prime pairs with a gap of 2. Mathematicians strongly expect the answer to be yes, but this remains an unsolved problem.
Gap of 4: Cousin Primes
Prime pairs separated by 4 are often called cousin primes. Examples include 3 and 7, 7 and 11, and 13 and 17. When the two primes are consecutive, the same distance is also a prime gap of 4.
Gap of 6: Sexy Primes
Prime pairs separated by 6 are called sexy primes. The name comes from the Latin word for six. Examples include 5 and 11, 7 and 13, and 23 and 29. Again, the pair counts as a prime gap only when no other prime lies between them.
Large Prime Gaps
A large prime gap is a long interval between one prime and the next. These gaps become more common as numbers grow because primes become thinner among larger integers.
For example, the gap between 89 and 97 is 8. That means 90, 91, 92, 93, 94, 95, and 96 are all composite numbers.
Longer gaps appear later. This does not mean primes stop appearing. It means we may need to pass through more composite numbers before finding the next one.
Important: Large prime gaps are not errors in the prime sequence. They are a natural part of how prime numbers spread out.
Prime Gaps Can Be Arbitrarily Long
There is no largest possible prime gap. Mathematicians can prove that prime gaps can be as long as we want.
One classic idea uses factorials. For any whole number n, the number n! means:
n × (n − 1) × (n − 2) × … × 2 × 1
Now look at this sequence:
n! + 2, n! + 3, n! + 4, …, n! + n
Each number in that list is composite. Why? Because n! + 2 is divisible by 2, n! + 3 is divisible by 3, and so on up to n! + n.
That gives a run of consecutive composite numbers. As n grows, the run can be made longer and longer. So prime gaps have no fixed upper limit.
Do Prime Gaps Grow Over Time?
Yes, on average, prime gaps grow as numbers get larger. This comes from the fact that primes become less dense among large numbers.
Near small numbers, primes are frequent. Near much larger numbers, primes are still infinite, but they appear less often. A useful estimate from prime number theory says that the average spacing between primes near a number x is about:
log(x)
Here, log means the natural logarithm. This does not predict every gap exactly. It gives a broad average. Individual gaps can be smaller or larger than the estimate.
Average Does Not Mean Regular
Prime gaps do not increase smoothly. A small gap can appear after a large one. Twin primes can still occur far out in the number line. This is one reason prime gaps remain an active subject in mathematics.
Think of the average as a trend, not a rule for each step.
Prime Gaps and Consecutive Primes
A prime gap only uses consecutive primes. This detail matters.
For example, 7 and 13 differ by 6. But they are not consecutive primes because 11 lies between them. So 7 and 13 are a prime pair with distance 6, but they do not form a prime gap of 6.
By contrast, 23 and 29 are consecutive primes. There is no prime between them. Their difference is 6, so this is a true prime gap.
How to Find a Prime Gap
To find a prime gap, you need two consecutive prime numbers. Then subtract the smaller prime from the larger prime.
- Start with a prime number.
- Find the next prime after it.
- Subtract the first prime from the next prime.
For small numbers, this can be done by hand. For larger numbers, it is better to verify primality carefully. You can use the Prime Number Checker to test whether a number is prime before comparing it with nearby numbers.
Prime Gaps vs Prime Distance
People sometimes use the phrase distance between primes in a loose way. A prime gap is more specific.
| Term | Meaning | Example |
|---|---|---|
| Prime gap | Distance between consecutive primes | 23 to 29 gives a gap of 6 |
| Prime distance | Distance between any two primes | 7 to 13 has distance 6, but 11 is between them |
This distinction helps avoid confusion when studying twin primes, cousin primes, and longer prime intervals.
Prime Deserts
A prime desert is an informal name for a long stretch of consecutive composite numbers. It is not a separate type of number. It is a region where no primes appear for a while.
Prime deserts are closely related to large prime gaps. If the gap between two consecutive primes is 20, then there are 19 numbers between them, and all of those middle numbers are composite.
The larger the gap, the longer the prime-free region.
Record Prime Gaps
A record prime gap is a gap that is larger than every prime gap before it. For example, early prime gaps include 1, 2, 2, 4, 2, 4, 2, 4, 6, and so on. When a new gap exceeds all earlier gaps, it becomes a record for that point in the sequence.
Record gaps are useful because they show how far primes can spread apart as numbers grow. They also give mathematicians data for testing ideas about prime distribution.
However, record gaps are not the same as average gaps. Most gaps near a given size are much smaller than the largest record gap found up to that range.
Prime Gaps and the Prime Number Theorem
The Prime Number Theorem describes how primes thin out as numbers get larger. It does not list the next prime, but it gives a strong estimate of how many primes appear below a given size.
One useful idea from this theorem is that primes near x tend to have an average spacing around log(x). This links prime gaps to the larger study of prime density.
For learners, the main point is this:
Prime numbers never end, but they become less frequent as numbers grow. Prime gaps are one way to measure that thinning.
Common Misunderstandings About Prime Gaps
Prime gaps are not random noise
Prime gaps may look irregular, but they follow deep arithmetic limits. For example, after 2, prime gaps must be even. Also, long composite runs can be created using factorials.
A large gap does not mean primes are running out
There are infinitely many prime numbers. A long gap only means there is a long local stretch with no primes.
Not every pair of primes forms a prime gap
Only consecutive primes form prime gaps. If another prime sits between two primes, their difference is not a prime gap.
Average gap is not the next gap
The average spacing near a number gives a broad estimate. It does not tell you the exact distance to the next prime.
Why Prime Gaps Are Still Studied
Prime gaps sit between simple arithmetic and advanced number theory. The definition is easy, but the behavior is hard to fully explain.
They connect to open questions such as the twin prime problem and to modern research on bounded gaps between primes. They also help learners see that primes are not just isolated numbers. Their spacing tells a story about the structure of the integers.
For practical use, prime gaps can also appear in algorithms that search for primes. When a program tests numbers near a target size, the distance to the next prime affects how many candidates may need to be checked.
FAQ
What is a prime gap?
A prime gap is the difference between two consecutive prime numbers. For example, the gap between 17 and 19 is 2.
How do you calculate a prime gap?
Find the next prime after a given prime, then subtract the first prime from it. If the primes are 23 and 29, the gap is 29 − 23 = 6.
Why are prime gaps usually even?
After 2, all prime numbers are odd. The difference between two odd numbers is even, so every prime gap after the first one is even.
Can prime gaps be very large?
Yes. Prime gaps can be made arbitrarily large. One proof uses factorials to create long runs of composite numbers.
What is the smallest prime gap?
The smallest prime gap is 1, between 2 and 3. After that, the smallest possible prime gap is 2, which occurs in twin prime pairs.
Are there infinitely many prime gaps of 2?
This is the twin prime problem. Mathematicians expect there are infinitely many twin prime pairs, but the question has not been fully solved.