Thought Toys · Chance & inference · Exhibit 63
No formula tells you how far the next prime is from this one — it could be 2 away, it could be 50. And yet the running count of primes below x tracks the smooth curve x/ln(x) closer and closer as x grows, with no exceptions. Drag x from a thousand to a million and watch both truths at once.
Gaps between the 30 primes just above x average gap ln(x)
—
—
π(x): —x/ln(x): —ratio: —
Primes thin out as numbers grow, but not smoothly. Walk along the number line near some large x and the gaps between consecutive primes jump around with no visible rhythm: a gap of 2 (a twin prime pair) can sit two doors down from a gap of 50 with nothing in between to warn you which is coming. Nobody has a formula that predicts the next one — the top chart is the actual gaps near your chosen x, and they scatter well above and below their own average with no sign of settling down, however far out you drag the dial.
And yet zoom out to the count — how many primes exist below x, written π(x) — and a law appears with no exceptions: π(x) divided by x/ln(x) drifts toward exactly 1 as x grows. It's a slow drift, honestly — even at a million it's still about 8% high, a reminder that "the limit is 1" is a statement about forever, not about being close by a million. Compare that to the naive guess that "half of all whole numbers are prime": that ratio doesn't just miss, it gets worse the farther out you go. One law converges. The other doesn't. The same primes produce both stories, depending only on whether you ask about the next one or about all of them — local unpredictability underneath global regularity.
improve/verify/63-prime-number-theorem.js): the sieve behind every number on this page
is cross-checked against independent trial division on 3,000 random integers up to 1,000,000 (zero
mismatches); π(x)/(x/ln x) measurably closes in on 1 from
1.16 at x=1,000 to 1.08 at x=1,000,000, while the naive π(x)/(x/2)
guess falls from 0.34 to 0.16 over the same range — negative control: getting worse,
not better. Separately, the 300 primes surrounding x=500,000 have gaps averaging 12.98
(ln(500,000)=13.12, matching the law) but ranging from 2 to 52 with a coefficient of variation of
0.71 — nowhere near the near-zero variation a genuinely regular, evenly-spaced control sequence
shows at the same average spacing — proof the local unpredictability is real, not an illusion of
the chart.
Also in Chance & inference: The Galton board →
← the cabinet · Thought Toys — a cabinet of explorable explanations. Exhibit 63.