Write in the middle of a sheet of squared paper, wind the next whole numbers around it in a square spiral, and mark every prime. The marks gather along diagonal lines, although the primes themselves come at irregular spacings. Where do the streaks come from, and does some line hold only primes? This page builds the spiral, shows that the numbers on each diagonal are the values of a quadratic polynomial, uses divisibility to explain why some diagonals are crowded with primes and others hold none, and shows why a formula that gives forty primes in a row still proves nothing about the next value.
Key terms
Ulam spiral
Definition The Ulam spiral places the positive whole numbers in the squares of a grid, one number per square. The number goes in a center square and in the square to its right. After that the path turns left, a quarter turn counterclockwise, whenever the square on its left is still empty, and otherwise goes straight on. So sits above , then and go to the left, and go down and and go to the right, which completes the first ring around at its lower right corner. Then the primes are marked. In a large spiral the marks cluster along diagonal lines, for two reasons. Every diagonal line holds only odd numbers or only even numbers, so half of the diagonals hold no prime except . And far enough from the center, the numbers on a diagonal line are the values of a quadratic polynomial, whose divisibility properties make some of the odd diagonals rich in primes and others poor. The picture raises good questions about primes, but it proves nothing about all of them. It is named after the mathematician Stanisław Ulam, who drew it in 1963.
In plain words Coil the counting numbers around a center and color the primes. The coil lines up numbers that follow simple formulas, and some of those formulas are friendlier to primes than others.
Example Here are the first two rings, the numbers to , with the primes in bold.
Color the grid like a checkerboard with on a dark square. Each step of the path moves to a neighboring square, which has the other color, and changes the number by . So the odd numbers all sit on dark squares and the even numbers on light ones. A diagonal line stays on one color, and a line of light squares, such as , holds no prime other than . The diagonal from the top left corner to the bottom right corner reads , and the other one reads , all odd.
Prime numbers
Definition A prime number is a whole number greater than whose only positive divisors are and itself. A whole number greater than that is not prime is composite, which means it is a product of two whole numbers that are both greater than . The number is neither prime nor composite. Every whole number greater than is a prime or a product of primes, in only one way apart from the order of the factors, and there are infinitely many primes, as Euclid proved. To test whether a whole number is prime, it is enough to try the primes up to as divisors. If with , then , and every prime factor of divides as well.
In plain words Primes are the whole numbers above that cannot be split into a product of two smaller whole numbers. Every other whole number above is built from them by multiplication.
Example The primes below are and , fifteen of them, and the gaps between neighbors, , change irregularly. To test , note that , so only , and need checking. The number is odd, its digit sum is not a multiple of , and it does not end in or , so is prime. The number ends in , and is composite.
Quadratic polynomial
Definition A quadratic polynomial in a variable is an expression with fixed numbers , and , where . At the differences between consecutive values grow by the same amount at every step, which makes a quadratic easy to recognize in a list of numbers. On the Ulam spiral, the number diagonal steps from in each of the four diagonal directions is
- lower right, ,
- lower left, ,
- upper left, ,
- upper right, ,
for every whole number . More generally, far enough from the center the numbers along any diagonal line, read outward in one direction, are the values of a quadratic polynomial with whole numbers and .
In plain words A quadratic polynomial is a formula whose highest power is a square. On the spiral the square comes from the square rings growing around the center, and the rest of the formula says how far around a ring the diagonal sits.
Example The ring at distance from the center is the border of a square of side . The numbers to fill that square, so the ring ends at its lower right corner with the number . Walking backward around the ring lowers the number by at each step. Going steps back along the bottom reaches the lower left corner, more up the left side reach the upper left corner, and more along the top reach the upper right corner. So the upper left corner holds
and the other corners follow in the same way. For the formulas give these numbers.
| Diagonal | First four numbers | Formula |
|---|---|---|
| Lower right | ||
| Lower left | ||
| Upper left | ||
| Upper right |
On the upper left diagonal the differences are , and , growing by each time, as a quadratic with requires. The lower right diagonal stands out in the picture as a line with no prime at all, because each of its numbers after is the square of an odd number greater than and so has that odd number as a factor.
Prime-generating polynomial
Definition A polynomial with whole number coefficients is called prime-generating on a range of whole number inputs when all of its values on that range are prime. Every such run ends. No polynomial in one variable with whole number coefficients, other than a constant, has a prime value at every whole number input. The reason is divisibility. If is prime, then is a multiple of for every whole number , because each power differs from by a multiple of . So , , and so on are all multiples of . A polynomial that is not constant takes the value at only finitely many inputs, so one of these multiples is different from , and then it is not prime. The best-known example, studied by Leonhard Euler, is . It is prime for each of the forty inputs , while
A spiral that starts with in the center instead of , and follows the same path, puts the values for on the diagonal line through the center from lower left to upper right, alternately on its two sides. Its center, the next squares toward the upper right and the next toward the lower left all hold primes, and the th square toward the lower left holds . No quadratic polynomial in one variable is known to take infinitely many prime values, not even .
In plain words A formula can give primes many times in a row and still fail at the next input. A long run of examples is evidence, not a proof.
Example The upper left diagonal, , gives the primes , and and then . Divisibility explains where the multiples of fall. When leaves remainder or on division by , the square leaves remainder , so leaves remainder , which means that it is a multiple of . That happens at , with the values , and only the first of them is itself. In the other direction, is always odd, and since leaves remainder or on division by , it leaves remainder or , so it is never a multiple of . Among to this diagonal holds primes, the upper right diagonal , the lower left and the lower right none. Whether the upper left diagonal holds infinitely many primes is not known. For the number can only be prime when is even, and gives , so the question is the same as whether is prime for infinitely many . Edmund Landau listed it in 1912 among four problems about primes, and it is still open.
Check yourself
- Use the lower left formula to find the numbers for to . Check the first two against the grid of the first two rings, and decide which of the five numbers are prime.
Show the answer
The formula gives and . The grid shows just below and to the left of , and in the lower left corner, as predicted. The number is prime and is not. For , the primes up to are , and , and none of them divides , so it is prime. For , the primes up to are , , and , and none of them divides , so it is prime. Finally . Three of the five numbers are prime.
- Write . It is prime for , and someone concludes that it is always prime. Find the first input where it fails, and explain why it must fail there without testing for primes. Which later inputs are sure to give multiples of ?
Show the answer
At the value is . The failure is built in, because , which at is , so the value is . More generally , and since is prime, is a multiple of exactly when or is. That happens at and so on, for example and . All of these values are larger than , so none of them is prime. This matches the argument in the definition, which starts from and finds the multiples , , and so on. Sixteen primes in a row were evidence, but the polynomial could never give primes forever. The polynomial fails at for the same reason, since .
- Show that never divides , and that divides exactly when leaves remainder on division by . What does this say about the lower left diagonal?
Show the answer
A whole number leaves remainder , or on division by , and then leaves remainder , or , since leaves remainder . Because leaves remainder , the number leaves the same remainder as , which is or and never . In the same way leaves the same remainder as . Since is prime, this square is a multiple of exactly when is, that is, when leaves remainder .
So on the lower left diagonal the squares at hold multiples of , such as , and , and since these are larger than they are composite. One square in three on that diagonal is ruled out by alone, while the upper left diagonal never loses a square to . That fits the counts of and primes among the first squares of these two diagonals. The upper right formula leaves the remainder of , so that diagonal loses the squares where leaves remainder , starting with at , after the prime itself at .