Skip to content

Prime Gaps: The Spaces Between Prime Numbers

    A prime gap is the space between two consecutive prime numbers. If one prime is followed by the next prime, the difference between them tells us how many steps separate them on the number line.

    Definition

    If pn is the nth prime number and pn+1 is the next prime after it, then the prime gap is the difference between those two primes.

    Prime Gap Formula

    gn = pn+1 − pn

    For example, the primes 11 and 13 are consecutive primes, so the gap is 13 − 11 = 2.

    What Prime Gaps Measure

    Prime gaps measure the spacing between primes, not the number of composite numbers only. A gap of 2 means the primes are separated by one integer between them. For 11 and 13, that integer is 12.

    The first prime gap is unusual: 3 − 2 = 1. After that, every gap between consecutive primes is even, because all primes greater than 2 are odd.

    Early Prime Gaps
    Consecutive PrimesCalculationPrime GapNumbers Between Them
    2 and 33 − 21None
    3 and 55 − 324
    5 and 77 − 526
    7 and 1111 − 748, 9, 10
    11 and 1313 − 11212
    13 and 1717 − 13414, 15, 16
    23 and 2929 − 23624, 25, 26, 27, 28

    How a Prime Gap Is Found

    To find a prime gap, first identify two consecutive prime numbers. Then subtract the smaller prime from the larger prime. The word consecutive matters: 7 and 13 are both prime, but they are not consecutive because 11 lies between them.

    Example

    The primes around 20 are 19 and 23. Since there is no prime between them, they are consecutive primes. The gap is 23 − 19 = 4.

    Checking whether numbers inside a gap are prime is part of the process. You can use PrimeOrNot’s prime number checker to test a number and see whether it is prime, composite, or neither.

    Test a Number Around a Prime Gap

    Enter a whole number and check whether it is prime before comparing it with nearby primes.

    Enter a number
    Works for integers up to 15 digits

    Why Most Prime Gaps Are Even

    Every prime number greater than 2 is odd. The difference between two odd numbers is always even, so every prime gap after the first one is even.

    Odd Prime Difference

    odd − odd = even

    That is why gaps such as 2, 4, 6, 8, 10 and larger even values appear between consecutive primes.

    This does not mean every even number appears as a prime gap in a simple pattern. Prime gaps are irregular, and their behavior is one reason prime numbers are studied deeply in number theory.

    Twin Primes and Prime Gaps

    A prime gap of 2 creates a pair of twin primes. Examples include 3 and 5, 5 and 7, 11 and 13, and 17 and 19.

    Prime Gaps and Related Prime Patterns
    Gap TypeMeaningExample
    Gap of 1Only happens between 2 and 32, 3
    Gap of 2Creates a twin prime pair11, 13
    Gap of 4Often called cousin prime spacing when the pair differs by 413, 17
    Gap of 6Often called Gap of 6 prime pair when the pair differs by 623, 29
    Large gapA long stretch of composite numbers between consecutive primes89, 97

    Prime Gaps Get Larger, But Not Smoothly

    As numbers grow, primes become less dense on average. This means that larger prime gaps become more common farther along the number line.

    The average spacing near a large number x is roughly related to log x, a natural logarithm term that appears in the Prime Number Theorem. This is an average idea, not a rule for predicting the next exact gap.

    Common Confusion

    A larger number does not guarantee a larger next prime gap. Small gaps can still appear among large primes, and larger gaps can appear earlier than expected. Prime gaps are uneven.

    There Are Prime Gaps of Any Size

    Prime gaps do not stay below one fixed limit. There are stretches of composite numbers as long as we want.

    One standard way to see this uses factorials. For a large whole number N, the numbers N! + 2, N! + 3, N! + 4 and so on up to N! + N are all composite, because each one is divisible by its added number.

    Math Note

    The factorial argument shows that arbitrarily long runs of composite numbers exist. It does not tell us the exact location of the next record prime gap, but it proves that prime gaps can be made very large.

    Prime Gaps and Prime Density

    Prime density describes how often prime numbers appear in a region of the number line. Near small numbers, primes are frequent. Farther out, they become thinner on average.

    Small Numbers

    Prime gaps are often short, such as 2 or 4.

    Large Numbers

    Prime gaps can be much longer, although short gaps can still appear.

    Prime Counting

    The prime counting function counts how many primes are less than or equal to a given number.

    Why Prime Gaps Matter

    Prime gaps connect simple arithmetic with deeper questions about how primes are distributed. They also help explain why prime numbers can feel regular in some places and unpredictable in others.

    FAQ About Prime Gaps

    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.

    What Is the Smallest Prime Gap?

    The smallest prime gap is 1, between 2 and 3. After that, prime gaps between consecutive primes are even.

    Why Are Most Prime Gaps Even?

    All primes greater than 2 are odd. The difference between two odd numbers is even, so every prime gap after 2 and 3 is even.

    What Prime Gap Creates Twin Primes?

    A gap of 2 creates twin primes. Examples include 11 and 13, 17 and 19, and 29 and 31.

    Can Prime Gaps Become Very Large?

    Yes. There is no fixed largest possible prime gap. Factorial reasoning shows that arbitrarily long runs of composite numbers exist.

    Do Prime Gaps Follow a Simple Pattern?

    No. Prime gaps have average trends, but the exact spacing between nearby primes does not follow a simple repeating pattern.