How the machine works
Every prime p is a ring cut into p slices, with one marker. On every beat all the rings turn one slice clockwise, so ring p's marker comes back to the top, to the gate, every p beats: exactly on the beats that p divides.
Number n arrives on beat n and tries to pass the gate.
- If a marker sits on the gate, the seat is taken: n is composite, and the rings on the gate are exactly its prime factors. On beat 36 rings 2 and 3 are there, and 36 = 2² · 3².
- If no marker is on the gate, n is prime: no smaller prime divides it. The gate stays clear and a new ring with n slices is born on it.
Why the chain never crosses the gate
The markers are joined in ring order, centre → 2 → 3 → 5 → 7 → …, like the rods of a steam engine. Each link is drawn with its angle measured clockwise from the gate, from 0 up to one full turn, and that angle is never wrapped around. A link sweeps from one marker's angle to the next one's, so where a straight rod would cut across 12 o'clock, the link goes around the back instead.
A link can only reach the gate at one of its ends, where a marker sits on the gate. So the chain touches the gate exactly at the rings of n's prime factors, and on a prime beat it does not touch the gate at all: the prime slips through.
The arcs simply move with the rings. A marker comes up to the gate from the back, with its links wrapped around the back; on the beat its ring divides, it sits on the gate and blocks it, and from that beat on its angle counts from 0 again, so its links leave the gate to the front. Nothing ever turns backwards. On a prime beat no marker is on the gate: the gate line points into empty space and the number passes. Switch on Straight rods to compare: straight rods cut across the gate on most beats, so a rod touching the gate would no longer mean that a ring sits on it.
| Beat | Rings on the gate | Links standing straight up the gate |
|---|---|---|
| 30 | 2 · 3 · 5 | 3 |
| 210 | 2 · 3 · 5 · 7 | 4 |
| 2 310 | 2 · 3 · 5 · 7 · 11 | 5 |
| 30 030 | 2 · 3 · 5 · 7 · 11 · 13 | 6 |
| 510 510 | 2 · 3 · 5 · 7 · 11 · 13 · 17 | 7 |
The inner rings decide everything
A composite number can be written as n = a × b with a ≤ b, so a ≤ √n: its smallest prime factor is at most √n. One of the inner rings, p ≤ √n, is always on the gate when n is composite. Up to 100 000 only the 65 rings p ≤ 316 ever decide. Whenever one of the other 9 527 rings blocks a number below 100 000, an inner ring blocks it too.
With thousands of rings the inner ones are too small to see, so switch on the Deciders lens: the rings p ≤ √n spread over most of the machine and all the others are squeezed into the outer band. Then zoom in (up to 400×): drag to move, scroll or pinch to zoom, double-click or double-tap to see the whole machine again. More ring names appear as the rings move apart.
At scale: a spiral with loops
Ring p's marker sits at the fraction n/p of a full turn (only the part after the decimal point counts). For the large rings this changes slowly from one ring to the next, so their markers line up into a spiral arm and their links join into a smooth spiral. Where the arm meets the gate, near the rings p ≈ n, n/2, n/3, …, the chain has to loop all the way around the back.
It is the sieve of Eratosthenes, played as a rhythm
Each ring marks its own multiples, one beat at a time, which is what the sieve of Eratosthenes does when it crosses out multiples. Nothing here predicts where the next prime will be: the machine shows the sieve at work, and the silences are the primes.
| Up to | Primes (silences) | Deciding rings p ≤ √n |
|---|---|---|
| 100 | 25 | 4 |
| 1 000 | 168 | 11 |
| 10 000 | 1 229 | 25 |
| 100 000 | 9 592 | 65 |
| 1 000 000 | 78 498 | 168 |
Sound
Sound stays off until you switch it on. A soft heartbeat marks every beat and every ring on the gate plays a soft chime; a prime beat has no chime. The notes come from a fixed chord progression, not from the primes, like the composed music of the videos. Above 8 beats per second the beat sounds are muted.
Share a state
The address bar follows the machine, so you can copy it. For example ?n=99991&lens=1 opens the
last prime below 100 000 with the lens on. Parameters: n, speed, lens,
rods, chain (all, 1000, 100, sqrt, 0), play and the view: z
(zoom), x and y (the point in the middle, in machine radii from the centre).