The Ulam spiral in this visualization
In 1963 Stanisław Ulam, bored during a talk, wrote 1 in the middle of a sheet of squared paper, 2 to its right, and carried on counter-clockwise round a square spiral. When he circled the primes they did not scatter evenly: many lined up along diagonals. The page also offers Sacks’s spiral (1994), which puts at radius and angle so that the squares all land on one ray, and a polar layout that puts at radius and angle radians.
Ring of the square spiral ends at , and each ring’s sides are 2 cells longer than the last. Walk out along a diagonal: once each step lands on the same side of the next ring, the jumps grow by exactly 8 per ring, so the numbers follow a quadratic in the ring number . The one running up and to the right from 1 is . A prominent diagonal is a quadratic with an unusually large share of prime values.
Euler noticed in 1772 that is prime for every from 0 to 39 (at it gives ). The reason it stays rich in primes is that its values are never divisible by 2, 3, 5 or any prime up to 37. A typical odd number is divisible by 3 a third of the time and by 5 a fifth of the time; these values never are, so far more of them are left prime: 581 of the first 1000, against under 8% of the numbers up to a million. Yet it is not even known whether , or any single quadratic, takes infinitely many prime values; Landau listed among four such problems in 1912.
In the polar layout the arms come from fractions close to . Six radians are just short of one turn, so and sit at nearly the same angle and the numbers fall into 6 slowly turning arms, one for each remainder on division by 6. Pulled back, 44 radians are almost exactly 7 turns (), giving 44 arms; further out, 710 radians are 113 turns and 0.00006 rad (), giving 710 rays. Apart from the primes that divide the step, every prime falls in a remainder coprime to the step: beyond 2 and 3, every prime leaves remainder 1 or 5 on division by 6, so the primes keep to 2 of the 6 arms, 20 of the 44 and 280 of the 710. Dirichlet proved in 1837 that each such arm holds infinitely many primes.
Things to notice
- The patterns do not make the primes predictable. They show the primes avoiding some remainders and some quadratics avoiding small divisors; which numbers along a prominent diagonal are prime still looks irregular.
- The polar arms belong to the layout, not to the primes: turn on “Others” and every number fills the same arms. The primes determine which arms stand out.
- The primes thin out: up to , about one number in is prime (the prime number theorem), so their share falls overall; the inset’s solid line shows the actual share.