Write the whole numbers 1, 2, 3 … in a square spiral that starts at the centre and turns outward.
Then colour the primes. Nobody designed the pattern into the spiral, yet it shows diagonal lines and bands. Stanisław
Ulam is said to have doodled this spiral in 1963 during a dull talk; the picture here is the one he is said to
have drawn.
What the numbers mean
A prime has exactly two divisors, 1 and itself. The sieve used here crosses out multiples of each prime in turn.
Every count on this page comes from that sieve, not from a formula.
The polynomial n² + n + 41 gives a prime for every n from 0 to 39. At n = 40 it gives 1681, which is 41².
Euler noticed this long ago; the spiral is one way to look at its values.
Turn on the highlight at a grid side of 61. The coloured cells sit on two straight diagonals. Counting from the
centre, the cells with x − y = 40 are eleven in a row, from the cell with 3701 to the one with 1681; the cells with
x − y = −40 are another eleven. I checked those coordinates in a separate script. I have not worked out why the
diagonals appear, and the page does not claim to explain them.
Hover over any cell to read its number. Composite cells show their smallest prime factor.