Skip to main content
Mental Models

Primes as Random Numbers

Despite being perfectly deterministic, prime numbers behave in many ways as if they were randomly distributed. This heuristic allows mathematicians to make probabilistic predictions about prime gaps, twin primes, and other patterns, which match observed data remarkably well.

THE IDEA

The Prime Number Theorem states that among the first N integers, about 1/log N of them are prime, so primes become rarer as numbers grow. The gaps between primes are irregular: some gaps are very small (like twin primes with gap 2) while others are large. Zhang's bounded gaps theorem proved that there are infinitely many prime pairs with gap at most 70 million, and this bound has since been reduced by collaborative work.

A key insight is that primes, though not random, often act as if they were random. For example, when dividing primes by 3, remainders 1 and 2 have the same asymptotic frequency (apart from the prime 3 itself, primes cannot have the excluded remainder). Using this randomness heuristic, one can estimate the frequency of twin primes: the chance that n and n+2 are both prime is about (1/log N)^2, leading to an expected count of about N/(log N)^2 twin primes up to N. Hardy and Littlewood refined this, accounting for dependencies, yielding a prediction that matches actual data (e.g., 1.1 trillion twin primes below a quadrillion).

Related discussions include Goldbach’s conjecture (every even integer >2 is a sum of two primes), the Green–Tao theorem (primes contain arbitrarily long arithmetic progressions), and Fermat’s Last Theorem (no positive-integer solutions to a^n + b^n = c^n for integer n>2). These are different kinds of results. Probabilistic intuition is not a proof, and the two named theorems have been proved using other mathematical arguments.

Zhang’s proof uses precise results about how primes are distributed among residue classes to establish bounded gaps. Such results can make parts of the randomness analogy rigorous without making primes independent random events.

When to use it

  • Predicting the number of prime pairs at large scales, like twin primes or cousin primes.

  • Testing conjectures in number theory by comparing actual data to random model predictions.

  • Guiding research into open problems (e.g., Goldbach conjecture, prime gaps) by supporting the intuition that they are likely true.

  • Developing new mathematical tools to formalize 'structured randomness' for deterministic sequences.

FROM THEORY TO EVERYDAY LIFE

In practice

01

Twin Prime Prediction

The unadjusted random model suggests a count on the scale N/(log N)^2. Applying the Hardy–Littlewood correction gives an estimate of roughly 1.1 trillion below a quadrillion, compared here with the reported count of 1,177,209,242,304. Agreement with data supports the heuristic without proving the twin-prime conjecture.

02

Bounded Gaps Heuristic

If primes were random, you would expect infinitely many pairs with gap 2. Zhang proved gaps less than 70 million appear infinitely often, consistent with this random behavior.

✳

A MOMENT TO REFLECT

Put it to work.

  1. How does the randomness heuristic change the way we think about prime distribution?

  2. Why is it surprising that a deterministic system like the primes can appear random?

  3. Can you think of other deterministic processes (e.g., digits of π) that might benefit from a similar probabilistic treatment?

References

  1. Prime Number Theorem — Hadamard, J. & de la Vallée-Poussin, C.J. (1896)
  2. Dirichlet's theorem on arithmetic progressions — Dirichlet, P.G.L. (1837)
  3. Twin prime prediction — Hardy, G.H. and Littlewood, J.E. (1923)
  4. Bounded gaps between primes — Zhang, Yitang (2013)
  5. Green–Tao theorem — Green, Ben and Tao, Terry (2004)
  6. Fermat's Last Theorem — Wiles, Andrew (1995)
  7. Beal conjecture — Beal, Andrew (1997)

CONTINUE THE CONVERSATION

Source texts

  • How Not to Be Wrong The Power of Mathematical Thinking (Ellenberg, Jordan)
← More mental models