The number spiral explained
Write the whole numbers round a spiral, one perfect square per turn, and colour the primes. Instead of a random scatter you see curves: some bright with primes, some empty. The number spiral turns a question about divisibility into a picture, and the curves it shows are the same quadratic polynomials that number theorists have studied since Euler.
From Ulam's square to Sacks' spiral
In 1963 Stanisław Ulam, doodling during a dull talk, wrote the numbers in a square spiral and circled the primes. They fell onto diagonal lines. Ulam's square has corners, though, where the lines break and change direction. In 1994 the software engineer Robert Sacks smoothed the idea out: he put the numbers on an Archimedean spiral instead, with exactly one turn between consecutive perfect squares. The diagonals of Ulam's square become smooth curves, and the whole pattern can be seen at once.
How the numbers are placed
Number n goes at distance √n from the centre, at an angle of √n full turns. So 0 is in the middle, 1 is one unit to the right after one full turn, 4 is two units to the right after two turns, and so on: every perfect square lands on the ray pointing right. Between two squares k² and (k + 1)² there are 2k numbers, and they share one turn of length about 2πk, so consecutive numbers are always about π apart along the spiral. The turns are one unit apart. The dots therefore cover the plane evenly, however far out you go.
Quadratics are curves
Take a quadratic x² + bx + c and plot its values for x = 0, 1, 2 ... Its square root is close to x + b/2 + (c − b²/4)/(2x), so the dots go round once per step of x and drift towards a fixed angle: the squares' ray when b is even, the opposite ray, where the pronic numbers k² + k lie, when b is odd. Every quadratic family therefore traces one curve that winds in towards one of those two rays. Each prime on the spiral sits on many such curves, and which curves light up is a matter of arithmetic.
Why some curves are full of primes
A curve is rich in primes when its values avoid small divisors. For an odd c the values of x² + x + c are always odd, because x² + x is even. Whether a prime p can divide x² + x + c depends on whether 1 − 4c is a square modulo p. For c = 41, 1 − 4c = −163, and −163 is not a square modulo any prime below 41, so no value of x² + x + 41 is divisible by 2, 3, 5, 7, ... or 37. Its values are prime far more often than ordinary numbers of the same size, and the curve shines on the spiral. A curve like x² + 2x + 1 = (x + 1)², on the other hand, holds only squares and never a prime.
Euler's lucky numbers
Euler found in 1772 that x² + x + 41 is prime for x = 0, 1, ..., 39. The same holds, for shorter runs, for x² + x + c with c = 2, 3, 5, 11 and 17: x² + x + 17 is prime for x = 0 to 15 and x² + x + 11 for x = 0 to 9. These six numbers are called Euler's lucky numbers, and there are no others. The reason is deep: they correspond to the Heegner numbers 7, 11, 19, 43, 67 and 163, the only values d for which the numbers a + b√−d (with suitable a and b) factor uniquely, a fact only proved in the 1960s.
Open questions
Nobody knows whether x² + 1 gives infinitely many primes. It is the fourth of the problems Edmund Landau listed in 1912 as unattackable, and it is still open, like every case of a quadratic. The Bunyakovsky conjecture predicts that a quadratic yields infinitely many primes unless something obvious, such as a common factor, prevents it, and Hardy and Littlewood's conjecture F even predicts how many: it gives a constant for each curve that measures how much brighter than average it should be. The spiral shows those constants at a glance.
Other numbers on the spiral
The squares make a straight ray to the right and the pronic numbers k(k + 1) a ray to the left. The triangular numbers k(k + 1)/2 are half of the pronic numbers; their square roots grow by about 1/√2 ≈ 0.71 per step, so each one is about 0.71 of a turn on from the one before, and together they form a handful of spiral arms that slowly twist. The Fibonacci numbers grow so fast that only a few of them fit, scattered dots further and further apart. Colouring several sets at once shows how they interlock: every triangular number is half a pronic number, and the squares are where each turn begins.
Explore it
Open the number spiral and grow it to a few thousand numbers with only the primes coloured: the curves appear at once. Choose Euler's x² + x + 41 under Curve and follow its ring of dots outwards; the Curve tile counts its primes and the unbroken run from the start. Try x² + x + 17, x² + 1 and your own b and c, point at a dot to see its prime factors, and press Play to watch the spiral grow from 0. The pencil opens the picture in the photo editor with the spiral, each set and the curve on layers of their own.
Frequently asked questions
Who invented the number spiral?
Robert Sacks, a software engineer, published it in 1994. It refines the square spiral of primes that Stanisław Ulam drew in 1963.
Why do the primes make curves on the number spiral?
Each curve holds the values of one quadratic x² + bx + c. Quadratics whose values avoid small divisors, such as x² + x + 41, produce primes much more often than average, so their curves look bright; others produce few or no primes.
Is there a formula that gives only primes?
No polynomial with integer coefficients gives only primes for every whole number x. Euler's x² + x + 41 comes famously close, with 40 primes in a row, but fails at x = 40.
Where are the perfect squares on the number spiral?
On a single ray pointing right from the centre, one per turn. The pronic numbers k(k + 1) lie on the ray pointing left.
Ready to try it?
Open PictorX in your browser — no install, no credit card required to start.
Open the number spiral