Lab 28

The numbers that will not break down

Every whole number is either a product of smaller ones or it is not, and the ones that are not are the primes. That is the entire definition, and almost everything else about them is hard. They thin out as you go, but never stop. They look scattered, but plot them the right way and lines appear. And nobody can prove the simplest-sounding things about them.

Sieve up to

1Cross out everything that is not prime

The oldest algorithm anyone still uses, from around 240 BC. Circle 2, then strike out every multiple of 2. Circle the next survivor, strike out its multiples, and repeat. Whatever is left standing never had a factor. Drag Sieve progress to watch it happen — and notice you can stop once you pass the square root, because anything left by then is prime already.

2Now wind them into a spiral

Write the whole numbers in a square spiral — 1 in the middle, then round and round — and light up only the primes. There is no reason this should produce anything but static. It does not: clear diagonal streaks appear. Each streak is a run of numbers of the form n² + n + c, and some of those formulas are unreasonably good at manufacturing primes. Stanisław Ulam noticed this doodling through a dull talk in 1963.

3How thinly do they spread?

π(x) counts the primes up to x. The claim — the prime number theorem — is that it grows like x / ln x. Below, the real count in green against that estimate, and against a better one that Gauss guessed at fifteen years old. The ratio column is the point: it crawls toward 1, but very slowly, which is why the theorem took a hundred years to prove.

xπ(x), countedx / ln xratioLi(x)

4The gaps between them

Consecutive primes are sometimes 2 apart and sometimes hundreds. The histogram is every gap in the range you sieved. Gaps that are multiples of 6 are conspicuously common — because past 3, every prime is one either side of a multiple of 6, so the gaps inherit that rhythm. Twin primes, the gap of 2, keep appearing however far out you go, and nobody has managed to prove they never stop.

Everything here was computed when you loaded the page

The sieve, the spiral, the counts and the gaps all run in your browser, on a plain array of bytes. Two million numbers sieve in a few milliseconds, which gives some sense of how good the algorithm is: it does barely more work than it takes to write the array down.

What it cannot show you is the hard part. Whether the twin primes go on forever is unproven. Whether every even number is the sum of two primes — checked to 4 × 10¹⁸ and never once failed — is unproven. And the Riemann hypothesis, which would pin down exactly how far π(x) can stray from the smooth estimate, has been open since 1859. These are not gaps in this page. They are gaps in mathematics.

Reference

Why anyone cares