Prime Distribution & the Prime Counting Function

Explore how primes thin out among integers, the Prime Number Theorem, and the race to count primes

How Are Primes Distributed?

Primes thin out as numbers grow, yet they never run dry. Up close they look random; from far away they follow a smooth, predictable curve.

The Prime Counting Function

Slide x and compare the staircase π(x) with x/ln(x) and Li(x). Notice how much closer Li(x) hugs the count.

01837552001π(x)x/ln(x)Li(x)

Prime Number Theorem: π(x) ~ x/ln(x) as x → ∞. The logarithmic integral Li(x) is a better approximation.

Go deeper:The Prime Counting Function

Primes become rarer as numbers grow, but how much rarer? The Prime Number Theorem (proved independently by Hadamard and de la Vallée-Poussin in 1896) gives the answer: the number of primes up to x is approximately x/ln(x).

But while the global trend is smooth, the local behavior of primes is wildly irregular. Prime gaps fluctuate unpredictably, and geometric arrangements of primes reveal mysterious patterns that remain unexplained to this day.

The function π(x) counts primes up to x. Compare it with two approximations: x/ln(x) (crude but famous) and Li(x), the logarithmic integral (far more accurate). Watch them converge as x grows — this is the Prime Number Theorem in action.

Prime Gaps

Look at the gaps between consecutive primes, then switch to the histogram. Twin primes, with gap 2, keep turning up.

022prime value
Twin (2)Cousin (4)Sexy (6)Found 199 pairs
Go deeper:Prime Gaps

The gaps between consecutive primes reveal the local irregularity beneath the smooth global trend. Twin primes (gap 2) are the closest pairs, while large gaps also appear. The twin prime conjecture — that there are infinitely many twin primes — remains one of the great open problems.

Prime Spirals

Each n sits at angle 2π√n and radius √n. Look for the curved lines of primes, then compare with the Archimedes spiral.

Sacks spiral: integer n placed at angle 2π√n, radius √n. Primes form striking radial lines.

Go deeper:Prime Spirals

Beyond the Ulam spiral, other geometric arrangements reveal different prime patterns. The Sacks spiral places n at angle 2π√n and radius √n, producing striking radial lines of primes that correspond to quadratic polynomials.

Bertrand's Postulate

Slide n and look between n and 2n. There is always at least one prime there.

5
6
7
8
9
10
n
11
12
13
14
15
16
17
18
19
20
2n
21
22
23
24
25
4 primes in (10, 20)
11, 13, 17, 19
Bertrand's Postulate: For every n > 1, there exists a prime p with n < p < 2n. Proved by Chebyshev (1850) and later by Erdős (1932) with an elementary proof.
Go deeper:Bertrand's Postulate

Despite their irregularity, primes are never too sparse: for every n > 1, there is always a prime between n and 2n. This was conjectured by Bertrand (1845) and proved by Chebyshev (1850), with a famously elegant proof later given by Erdős at age 19.

Key Takeaways

  • The Prime Number Theorem: π(x) ~ x/ln(x)
  • Prime gaps and the twin prime conjecture
  • Geometric patterns in spiral arrangements
  • Bertrand's Postulate: primes are always nearby

Spot a mistake or have an idea?

Search