ExplorationsDiagonals in the primes, and diagonals in the paper
The Spiral, and What It Is Not
Write 1 at the centre of a square grid and continue with 2, 3, 4 and so on in an outward spiral. Mark the primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself., the whole numbers greater than 1 divisible only by 1 and themselves. DiagonalDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid. streaks appear among the marks; the question is which number formulas create them and whether those formulas produce infinitely many primes.
Current view: The spiral
The integers wound into a square spiral, with the primes marked.
- number
- one whole number in the cell the spiral gave it
- circled
- that number is prime
- the centre
- the cell holding 1, where the winding starts
The centre cell holds the starting number, the next is one step east, and the walk turns anticlockwise from there. At the smallest size every number is printed and the primes are circled; above that each number becomes one square, filled when it is prime and blank when it is not. Look along the diagonals rather than the rows: those are the lines the marks gather on.
The numbers 1 to 121 wound into a spiral, with 30 of the 121 circled as prime. Look along the diagonals: the densest one here holds 7 of its 9 cells, which at this size settles nothing and is only here so that a diagonal is something you have seen before a larger field asks you to judge one.
- Field
- 11 × 11 from 1
- Primes
- 30 · 24.8%
- Densest diagonal
- 7/9 · 77.8%
The same data as a table
| Direction | Offset | Cells | Marked | Share |
|---|---|---|---|---|
| north-west to south-east | -2 | 9 | 7 | 77.8% |
| south-west to north-east | -2 | 9 | 6 | 66.7% |
| south-west to north-east | 2 | 9 | 5 | 55.6% |
| south-west to north-east | 0 | 11 | 6 | 54.5% |
| north-west to south-east | 0 | 11 | 4 | 36.4% |
| north-west to south-east | 2 | 9 | 3 | 33.3% |
| south-west to north-east | 1 | 10 | 1 | 10.0% |
| north-west to south-east | 1 | 10 | 1 | 10.0% |
| south-west to north-east | -1 | 10 | 0 | 0.0% |
| north-west to south-east | -1 | 10 | 0 | 0.0% |
| south-west to north-east | -3 | 8 | 0 | 0.0% |
| south-west to north-east | 3 | 8 | 0 | 0.0% |
| north-west to south-east | -3 | 8 | 0 | 0.0% |
| north-west to south-east | 3 | 8 | 0 | 0.0% |
Build it up
Every number printed and every prime circled, so the winding can be followed with a finger and the marks checked by eye.
Begin at eleven, where every number is printed and every circle can be checked. Each larger rung is the same winding with the printing taken away.
Centre value
The ordinary spiral, wound from 1.
Cases worth seeing
Try this
Open the control view and cover the labels. Can you tell which field is the primes? Then change the seed a few times and see whether your rule still works.
What is going on
Each explanation begins with a worked example and follows the same operation through intuition, formal statements and proofs. Later sections distinguish what is established from questions that remain open, so you can follow the level of detail useful to you.
- 1start at the centre(0, 0)1 is not primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself.
- 2one step east(1, 0)primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself., so it is circled
- 3left is empty, so turn north(1, 1)primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself., circled
- 4left is empty, so turn west(0, 1)2 × 2
- 5left is taken by 1, carry on west(−1, 1)primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself., circled
- 6left is empty, so turn south(−1, 0)2 × 3
- 7left is taken by 1, carry on south(−1, −1)primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself., circled
- 8left is empty, so turn east(0, −1)2 × 4
- 9left is taken by 1, carry on east(1, −1)3 × 3
Now keep going, and stop writing the numbers: draw a filled square wherever the number that landed there is primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself., and leave the cell blank wherever it is not. Nine numbers give the ring above. A quarter of a million give the picture in the laboratory.
The marks do not scatter. They fall along diagonalDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid. lines, some of which run clear across the field. On the 201-cell field centred on 41, one diagonal is primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. in 157 of its 201 cells while the field as a whole is only 10.5% prime. Nobody has proved that a single one of those lines carries on.
What you are seeing
A plain description of the process
Write 1, then 2 to its east, and keep going in an anticlockwise square spiral: 3 above 2, then 4 and 5 to the west, then 6 and 7 down, then 8 and 9 across, and outwards for as long as you like. Every whole number gets exactly one cell, and every cell gets exactly one number.
Now mark the cells holding primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself..
That is the whole construction. Stanisław Ulam did it on a scrap of paper during a lecture in 1963, and what appeared was not the even haze you would expect from numbers that thin out slowly. It was a set of diagonalDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid. streaks.
The one thing this page insists on is the comparison, and it is worth being exact about what it compares. Looking at this picture, you do not assess one diagonalDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid.: you scan several hundred of them and stop at the darkest, and the darkest of several hundred lines is well above the average even when the marks were scattered by a coin. So the laboratory draws the same field twice, once with the primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. and once with the same number of cells marked from a seed, measures the best line in each the same way, and prints both numbers.
Why it starts to make sense
Intuition, before any algebra
Start with the drawing rather than the primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself..
Walk out from the centre in a straight diagonalDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid. line, one cell at a time. Each step takes you one ring further out, and each ring is longer than the last by a fixed amount, so the numbers you pass grow at a steady second difference. That is precisely what a quadraticDefinition: A quadratic expression or equation has a highest power of two. does. Walk along a row instead and you cross the spiral sideways, hopping between rings in a way that has no such formula. Diagonals are special in this picture before the primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. are ever mentioned.
So the question becomes: are some quadraticsDefinition: A quadratic expression or equation has a highest power of two. much better at producing primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. than others?
They plainly are, for a reason with no depth to it at all. Take a diagonalDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid. whose values are all even: every one of them past 2 is compositeDefinition: A composite number is an integer greater than one with a divisor other than one and itself., so that whole line is blank. Take a diagonal whose values are never divisible by 3, and it has already dodged one of the commonest reasons for a number to be composite, so it should be richer than average. Every small primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. that a quadraticDefinition: A quadratic expression or equation has a highest power of two. avoids pushes its output further towards being prime, and the effect multiplies.
That gets you as far as expecting some variation between diagonalsDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid.. What it does not get you is a reason for any particular line to run 157 primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. long. For that, the honest answer is in layer 6.
The key idea
A diagonalDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid. is a quadraticDefinition: A quadratic expression or equation has a highest power of two.
Ring of the spiral holds the numbers from up to , so it holds of them, and its four corners are
Those four sequencesDefinition: A sequence is an ordered list of values, usually indexed by whole numbers. are the four main diagonalsDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid., and every other diagonal is one of the same shape with a different constant. Write and for the cell at : the arm heading north-east from it is
and the other three arms are , and . In every case the leading coefficientDefinition: A coefficient is a number or expression multiplying a chosen variable or term. is 4 and is the ring number.
Now put 41 in the centre instead of 1. Every value shifts up by 40, and the north-east arm of the main diagonalDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid. becomes . Substitute for odd and that is ; the opposite arm gives the same polynomialDefinition: A polynomial is a finite sum of terms made from coefficients and variables raised to non-negative integer powers. at even . So the diagonal through the centre of the 41-spiral is Euler's polynomial, read outwards in both directions - which is why that one line is so much darker than anything near it, and why the laboratory offers 41 as a starting value at all.
Euler's polynomialDefinition: A polynomial is a finite sum of terms made from coefficients and variables raised to non-negative integer powers. is primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. at . Forty values in a row, no exceptions. At it is 1681, which is .
Formal statement
Precisely what is being claimed
The diagonalsDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid.. For a spiral centred on with 1 at ring 0, the number in the cell is where and is one of the four quadraticsDefinition: A quadratic expression or equation has a highest power of two. above, chosen by which arm the cell lies on. Every diagonal of the spiral therefore has the form .
Euler's polynomialDefinition: A polynomial is a finite sum of terms made from coefficients and variables raised to non-negative integer powers.. is primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. for and compositeDefinition: A composite number is an integer greater than one with a divisor other than one and itself. at .
No polynomialDefinition: A polynomial is a finite sum of terms made from coefficients and variables raised to non-negative integer powers. is primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. everywhere. If is a non-constant polynomial with integerDefinition: An integer is a whole-number value, including zero and negative whole numbers, with no fractional part. coefficientsDefinition: A coefficient is a number or expression multiplying a chosen variable or term., there is some non-negative integer with not prime.
What is conjectured. For a quadraticDefinition: A quadratic expression or equation has a highest power of two. with , , not a product of two integerDefinition: An integer is a whole-number value, including zero and negative whole numbers, with no fractional part. polynomialsDefinition: A polynomial is a finite sum of terms made from coefficients and variables raised to non-negative integer powers., and odd, the Hardy-Littlewood ConjectureDefinition: A conjecture is a precise mathematical claim supported by evidence but not yet proved. F predicts that the number of with primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. is asymptotically
with an explicit constant built from how behaves moduloDefinition: The modulo operation gives the remainder after division by a chosen positive integer. each primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself., and the counting is of inputs rather than of values . This is the statement that would explain the picture, and it is not a theoremDefinition: A theorem is a mathematical statement established by a proof from accepted definitions and earlier results.. Not one instance of it is known - it is not even known that is prime infinitely often.
Proof
Two things, both complete
1. Every diagonalDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid. is a quadraticDefinition: A quadratic expression or equation has a highest power of two. in the ring number.
Ring begins at at the cell and runs anticlockwise through four sides of cells. On the east side, the cell carries . Take a cell with and follow the north-east arm: far enough out the cell is on that east side, so its number is
If instead the arm runs up the top side, where the cell carries ; substituting gives the same expression. The other three arms follow by the same substitutionDefinition: Substitution replaces specified symbols or expressions according to a stated rule. on the remaining two sides, with the south-east arm splitting into two cases because the ray , is the seam where each ring closes at and the next begins.
2. No non-constant integerDefinition: An integer is a whole-number value, including zero and negative whole numbers, with no fractional part. polynomialDefinition: A polynomial is a finite sum of terms made from coefficients and variables raised to non-negative integer powers. is primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. at every non-negative integer.
Suppose has integerDefinition: An integer is a whole-number value, including zero and negative whole numbers, with no fractional part. coefficientsDefinition: A coefficient is a number or expression multiplying a chosen variable or term., is non-constant, and is primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. for every . Let , which is then prime.
For any integersDefinition: An integer is a whole-number value, including zero and negative whole numbers, with no fractional part. and , divides , since it divides for every . Take and : then , and , so
But was assumed primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself., and a prime divisible by is itself. So for every - infinitely many solutions of . A non-zero polynomialDefinition: A polynomial is a finite sum of terms made from coefficients and variables raised to non-negative integer powers. has at most roots, so is identically zero and is constant, contrary to assumption.
So Euler's run had to stop. The proofDefinition: A proof is a finite argument showing that a conclusion follows from stated assumptions. says nothing about when, and 40 is a long way from obvious; what it forbids is the thing a reader looking at forty primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. in a row is tempted to believe.
Limits and frontier
Where this page stops being able to help
The control is the argument, and it controls for the search. Reading this picture means scanning several hundred lines and stopping at the darkest one, and the darkest of several hundred lines is far above the average even when the marks mean nothing. On the 201-cell field centred on 41 the seeded control reaches 21 marks in 113 cells, or 18.6%, against a field average of 10.5%
- that whole excess is the price of looking at every line. The primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. reach 157 in 201, or 78.1%. The gap between those two numbers is what this page has to offer: it is real, it is reproducible from the seed in the URL, and it is not a theoremDefinition: A theorem is a mathematical statement established by a proof from accepted definitions and earlier results. about anything.
Note what the control does not say. The random marks are placed uniformly, so they have no preferred direction, and the streaks you can find in them are alignments rather than structure the spiral imposed. The spiral's contribution is the one layer 5 proved: it turns lines into quadraticsDefinition: A quadratic expression or equation has a highest power of two., which is what lets a set as structured as the primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. concentrate on one at all.
Nothing here is known about the primesDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself.. The statement that would explain the picture is ConjectureDefinition: A conjecture is a precise mathematical claim supported by evidence but not yet proved. F, unproved since 1923. Its weakest recognisable consequence, that some quadraticDefinition: A quadratic expression or equation has a highest power of two. takes infinitely many prime values, is also unproved. Every dense diagonalDefinition: A diagonal joins non-neighbouring polygon vertices, or follows matching row-and-column steps through an array or grid. on this page is a finite observation about a finite field, and would remain one if the field were a billion cells wide.
Why 41. The run of forty is not luck. is primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. for every exactly when the imaginary quadraticDefinition: A quadratic expression or equation has a highest power of two. field of discriminant has class number one, a criterion of Rabinowitsch from 1913; those discriminants are known, and is the largest value that works. So 41 is the end of that pattern, and that much is settled - by machinery from a different part of mathematics entirely, not by anything visible in the picture.
Be careful with what it settles. It says no larger keeps primeDefinition: A prime number is an integer greater than one whose only positive divisors are one and itself. all the way to ; it does not say that no other polynomialDefinition: A polynomial is a finite sum of terms made from coefficients and variables raised to non-negative integer powers. anywhere has a longer opening run of primes, and this page makes no claim either way about that.
What this page is for. It is a lesson in what a striking image is worth. The spiral is the most reproduced picture in recreational number theory and it is almost always shown without its control, which makes it an argument that cannot be examined. Shown with one, it becomes something better: a real effect, honestly measured, sitting on top of an artefact of the drawing, with no proofDefinition: A proof is a finite argument showing that a conclusion follows from stated assumptions. of the first and a three-line proof of the second.
What is actually established
Every statement on this page, with its status, its exact scope, and the date that status was last checked.
n² + n + 41 is prime for every n from 0 to 39, and at n = 40 it is 1681 = 41².
- Scope
- The 41 integers n = 0 to 40.
- Why
- A finite statement about 41 specific numbers, each of which was checked. That is a proof of exactly what it says and of nothing more: it establishes the run and its ending, not that some other polynomial behaves the same way. The ending is not an accident either: n² + n + 41 is n(n + 1) + 41, which is divisible by 41 exactly when 41 divides n(n + 1), and the first n above zero where that happens is 40.
- Status checked
No non-constant polynomial with integer coefficients is prime at every non-negative integer.
- Scope
- Every non-constant polynomial with integer coefficients.
- Why
- Suppose f were. Then p = f(0) is prime, and f(kp) ≡ f(0) ≡ 0 modulo p for every k, so each f(kp) is a prime divisible by p and therefore equal to p or −p. A non-constant polynomial takes any single value only finitely often, so this cannot hold for every k. The proof is written out in full in layer 5.
- Status checked
Every diagonal of the square spiral is generated by a quadratic 4n² + bn + c, where n is the ring number.
- Scope
- All four diagonal directions from any cell of the spiral, at any starting value.
- Why
- Ring n begins at (2n − 1)² + 1 and ends at (2n + 1)², so a cell’s number is a quadratic in its ring number, and moving one step along a diagonal moves out exactly one ring. Substituting the four side formulas gives 4n² − 2n + (1 − u), 4n² + 2n + (1 + u), 4n² + (1 − v) and 4n² ± 4n + (1 + v), where u = x − y and v = x + y. This is the whole reason a diagonal can be special at all: a line of the picture is a polynomial, and a polynomial can avoid small divisors in a way an arbitrary line of cells cannot.
- Status checked
The primes gather on some diagonals of this spiral far more than a random set of the same size does.
- Scope
- The 201 × 201 field centred on 41 that this laboratory draws. Its densest long diagonal holds 157 primes in 201 cells, against 10.5% of the whole field; the seeded control at the same size and density manages 21 in 113 on its best long line.
- Why
- Measured here, not established. The comparison only counts diagonals at least half the field long, because a three-cell line in a corner with two marks on it is 67% dense and means nothing. The control is there because the number being compared is the best of several hundred lines, and the best of several hundred lines of pure noise is already 18.6% against an average of 10.5%. Change the size, the centre or the seed and all of these move, which is exactly why this is an observation of one configuration rather than a fact about the primes.
- Computation (exact)
- Exact integer arithmetic over the 40,401 numbers from 41 to 40,441, sieved in your browser, with every diagonal at least 101 cells long counted. The control is a partial Fisher-Yates shuffle from seed 1963 carrying the same number of marks. Algorithm ulam-1.
- Status checked
How many primes a quadratic an² + bn + c produces is predicted by the Hardy-Littlewood Conjecture F, which is unproved.
- Scope
- Every quadratic with integer coefficients that is not forced to be composite. No case of the conjecture has been proved, including the weaker statement that n² + 1 is prime infinitely often.
- Why
- Conjecture F gives an asymptotic count with an explicit constant built from how the polynomial behaves modulo each prime, and it is the only account anyone has of why one diagonal of this picture should be richer than its neighbour. It has stood since 1923. Nobody has even proved that a single quadratic takes infinitely many prime values, so the explanation this page would most like to give is unavailable.
- Status checked
Sources
Review notes show which bibliographic details Mathomaly has checked and which remain unresolved. Checking a publication record does not independently verify its proof.
- M. L. Stein, S. M. Ulam, M. B. Wells, A visual display of some properties of the distribution of primes, The American Mathematical Monthly 71(5), pp. 516–520, 1964. Link
The 1964 paper studies patterns in the distribution of primes using visual displays. The journal record, rather than the full article, was inspected.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: publisher record.
The journal contents confirm the authors, title, date and pages.
- Martin Gardner, Mathematical Games: The remarkable lore of the prime numbers, Scientific American 210(3), p. 120, 1964. Link
The column that put the spiral on a cover and made it famous. Cited for how the picture travelled, not for any mathematical claim.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: publisher record.
Publisher confirms Gardner, March 1964, volume 210(3), starting page 120.
- G. H. Hardy, J. E. Littlewood, Some problems of 'Partitio numerorum'; III: On the expression of a number as a sum of primes, Acta Mathematica 44, pp. 1–70, 1923. Link
Conjecture F predicts prime values of suitable irreducible quadratics. It offers a conjectural explanation for differing diagonal densities, not a proof that any particular quadratic produces infinitely many primes.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: source text.
University-hosted original confirms authors and article identity.
- Leonhard Euler, Extrait d'un lettre de M. Euler le pere à M. Bernoulli concernant le Mémoire imprimé parmi ceux de 1771, p 318, Nouveaux Mémoires de l'académie royale des sciences de Berlin, volume for 1772, pp. 35–36 (Eneström E461), 1774. Link
The published letter includes Euler's observation about x² − x + 41, equivalent to the page's n² + n + 41 after shifting the input by one. The academy volume is labelled 1772 but was published in 1774.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: library record.
The University of the Pacific's Euler Archive identifies the published letter, its actual title, E461, publication in 1774 and the 1772 volume. This replaces the descriptive placeholder citation; the original scan was not retrievable.
- Georg Rabinowitsch, Eindeutigkeit der Zerlegung in Primzahlfaktoren in quadratischen Zahlkörpern, Journal für die reine und angewandte Mathematik 142, p. 153, 1913. Link
The criterion that says exactly when n² + n + c is prime for all n below c − 1: precisely when the imaginary quadratic field of discriminant 1 − 4c has class number one. That is why 41 is the largest such c, and why no longer run of this shape exists.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: publisher record.
Publisher confirms author, article title and 1913 volume 142.
- A005846 - Primes of the form n² + n + 41, The On-Line Encyclopedia of Integer Sequences. Link
The values this page prints for the diagonal strip, checked against a published listing as well as recomputed from the kernel.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: source text.
Checked the sequence identifier, definition and displayed initial terms on the database entry.
Related by mechanism
Connected by how they work, not by sharing a topic label.