Geometry

Six numbers that need five pentagons

In 1638 Fermat wrote that every whole number is a sum of three triangular numbers, four squares, five pentagonal numbers, six hexagonal numbers, and so on for every polygon — and that he had a proof he would not write down. The claim is true; Cauchy proved it in 1813. What the claim hides is how unequal the cases are. Triangles and squares need their full count infinitely often. For pentagons, only six numbers ever need all five — 9, 21, 31, 43, 55 and 89 — and from hexagons on, two apiece.

Worth reading first: Three triangular numbers, and no fewer · Every square is a stack of odd numbers.

Three triangular numbers, and no fewer began with a line from Gauss’s diary for 10 July 1796: num = Δ + Δ + Δ — every whole number is a sum of three triangular numbers. Gauss was proving one case of a much larger claim. In 1638 Pierre de Fermat wrote in a letter that every number is a sum of three triangular numbers, four squares, five pentagonal numbers, six hexagonal numbers, “and so on to infinity”, and that he had a remarkable proof which the margins of his letters were too narrow to hold.

Joseph-Louis Lagrange proved the four-square case in 1770; Gauss the triangular case in 1796. Augustin-Louis Cauchy proved the whole claim, every polygon at once, in 1813. So Fermat was right. But the statement “five pentagonal numbers suffice” conceals a question it does not ask: how often are all five actually needed?

The fewest pentagonal numbers adding to each number up to 120. Fewest pentagonal numbers summing to 1..120; the most ever needed up to 20000 is 5, by 9, 21, 31, 43, 55, 89.
Fig. 1 The numbers 1 to 120, each shaded by the fewest pentagonal numbers that add up to it — lightest for one, darkest for five. Up to twenty thousand, only 9, 21, 31, 43, 55 and 89 need all five: every other number needs fewer, and past 89 none needs more than four.

The answer, in the figure, is almost never. The pentagonal numbers are 1,5,12,22,35,51,70,92,…1, 5, 12, 22, 35, 51, 70, 92, \ldots. Most numbers up to 120120 are sums of two or three of them. Six numbers in the whole range examined, up to twenty thousand, need all five, and the last of them is 8989. After that, four always suffice — and for most numbers far fewer.

A claim made in a letter

Fermat’s statement appears in a letter of September 1638 to Marin Mersenne, and again in the margin of his copy of Diophantus’s Arithmetica, the book whose margin also holds his most famous claim. Diophantus had discussed polygonal numbers in the third century, in a treatise of which a fragment survives, and Fermat described his result as among the most beautiful in all of arithmetic, promising a book on it that he never wrote.

Leonhard Euler spent years on the four-square case and proved a key step — that the product of two sums of four squares is again a sum of four squares, the identity behind the integers among the quaternions — without finishing it. Lagrange finished it in 1770, using Euler’s identity. Gauss’s triangular case, in 1796, needed his new theory of quadratic forms. And Cauchy’s general proof, in 1813, used both of the first two cases as tools. Every step of the proof leans on the squares, which is why the squares case had to come first.

What Fermat’s own proof was, if he had one, is unknown. His favourite method was infinite descent — showing that a counterexample would produce a smaller counterexample, and so on forever, which whole numbers cannot do — and he claimed to have used it for the four-square case. No descent proof of the general polygonal theorem has ever been found, and every proof since Cauchy’s goes through sums of squares instead. It is possible that Fermat had a proof of the cases he mentioned first and generalised by analogy, as he did elsewhere with claims that turned out to be false. Here, the analogy held.

Polygons of dots

The kk-gonal numbers count dots arranged in nested regular polygons with kk sides.

The pentagonal numbers as nested 5-gons. The first 5 pentagonal numbers, 1, 5, 12, 22, 35, as nested polygons of dots.
Fig. 2 The first five pentagonal numbers drawn as nested pentagons of dots sharing one corner — 1, 5, 12, 22, 35 — each new shell, in a new colour, adding three sides of dots. The m-th pentagonal number is (3m2−m)/2(3m^2 - m)/2.

Start with one dot. Draw a pentagon of side one with that dot as a corner: five dots. Draw a pentagon of side two sharing the same corner, and add the dots on its three new sides: twelve. Each new shell adds the three sides that do not touch the shared corner, so the shells grow by three dots at a time, just as odd numbers are squares found the square numbers growing by odd numbers — the gnomon of a square is two sides, of a pentagon three. Every polygonal family is built by the same rule with a different number of new sides per shell, and so every family is a sequence of second differences constant at k−2k - 2. The general formula is

Pk(m)=(k−2)m2−(k−4)m2,P_k(m) = \frac{(k-2)m^2 - (k-4)m}{2},

which gives the triangular numbers 1,3,6,10,…1, 3, 6, 10, \ldots at k=3k = 3, the squares at k=4k = 4, and the pentagonal numbers 1,5,12,22,…1, 5, 12, 22, \ldots at k=5k = 5. The figure checks each drawn pentagon against the formula, dot for dot.

The hexagonal numbers as nested 6-gons. The first 4 hexagonal numbers, 1, 6, 15, 28, as nested polygons of dots.
Fig. 3 The first four hexagonal numbers — 1, 6, 15, 28 — as nested hexagons sharing a corner, each shell adding four sides of dots. The hexagonal numbers are exactly the triangular numbers of odd index.

Hexagonal numbers are built the same way with four new sides per shell: 1,6,15,28,45,…1, 6, 15, 28, 45, \ldots. They happen to be every other triangular number — the triangular numbers T1,T3,T5,…T_1, T_3, T_5, \ldots — because a hexagon of dots can be cut into triangles. The polygonal families are not independent of one another, and that interdependence is part of why the theorem has a single proof.

From triangles to octagons

The same count can be run for every kind of polygon, and the results sort themselves into two groups.

How many polygonal numbers each kind needs, and who needs them all. triangular: 3, needed by 10650 numbers up to 20000; square: 4, needed by 3331 numbers up to 20000; pentagonal: 5, needed by 9, 21, 31, 43, 55, 89; hexagonal: 6, needed by 11, 26; heptagonal: 7, needed by 13, 31; octagonal: 8, needed by 15, 36.
Fig. 4 For each kind of polygonal number, the most of them any number up to twenty thousand needs — always exactly the number of sides — and which numbers need that many. For triangles and squares the full count is needed thousands of times; from pentagons on, only a handful of small numbers ever need it.

For triangular numbers, three are needed by more than half of all numbers up to twenty thousand: 55, 88, 1414, and so on. For squares, four are needed by every number of the form 4a(8b+7)4^a(8b + 7) — 77, 1515, 2323, 2828, 3131, … — a family that never ends, as Legendre’s three-square theorem says, and the integers among the quaternions proved that four always suffice.

Then the pattern changes. Pentagonal numbers need five only for the six numbers of the first figure. Hexagonal numbers need six only for 1111 and 2626. Heptagonal numbers need seven only for 1313 and 3131; octagonal numbers need eight only for 1515 and 3636. For triangles and squares Fermat’s bound is the truth for infinitely many numbers; for every larger polygon it is the truth for a few small ones and a gross overestimate for everything else.

Why the small cases are the hard ones

The reason the full count is needed only for small numbers from pentagons on is visible in the first few polygonal numbers themselves.

Consider hexagonal numbers: 1,6,15,28,45,…1, 6, 15, 28, 45, \ldots. To make 1111 from them, the largest usable is 66, leaving 55, which needs five ones: six hexagonal numbers in all, 6+1+1+1+1+16 + 1 + 1 + 1 + 1 + 1. There is no alternative, because nothing between 11 and 66 is hexagonal. Small numbers have few polygonal numbers below them, and the gap between 11 and the next one, kk, forces up to k−1k - 1 ones. For larger numbers, many polygonal numbers are available, their sums cover the numbers densely, and the count drops.

The fewest hexagonal numbers adding to each number up to 120. Fewest hexagonal numbers summing to 1..120; the most ever needed up to 20000 is 6, by 11, 26.
Fig. 5 The numbers 1 to 120 shaded by the fewest hexagonal numbers that add to each: up to twenty thousand, only 11 and 26 need all six, and most numbers need two, three or four.

The same arithmetic explains why triangles and squares behave differently. Their full counts are forced not by small gaps but by congruences: a sum of three squares can never be 77 more than a multiple of 88, so every such number needs four, however large. Three triangular numbers suffice for every number but two do not, and the numbers that need three are forced by a similar condition on sums of two squares, which three triangular numbers, and no fewer translated. For pentagons and beyond, no congruence obstructs a sum of k−1k - 1 polygonal numbers, and only the small cases, with their gaps, need the full count.

The same two exceptions, every time

From hexagons on, the numbers that need all kk follow a formula. For hexagons they are 1111 and 2626; for heptagons 1313 and 3131; for octagons 1515 and 3636. In each case they are 2k−12k - 1 and 5k−45k - 4, and a search to twenty thousand confirms the same pair, and nothing else, for every polygon from six sides to thirteen.

Both are easy to account for. The two smallest kk-gonal numbers after 11 are kk and 3k−33k - 3. The number 2k−12k - 1 is too small to use 3k−33k - 3, and using kk once leaves k−1k - 1, which can only be made of ones: 1+(k−1)=k1 + (k - 1) = k terms, and using no kk at all is worse. The number 5k−45k - 4 can be made as four copies of kk and k−4k - 4 ones, again kk terms in all; using 3k−33k - 3 instead leaves 2k−12k - 1, which, as just seen, needs kk terms of its own. Every other number has a cheaper route, because once 3k−33k - 3 and larger polygonal numbers can be combined, the gaps that force long strings of ones close up.

For pentagons, 2k−1=92k - 1 = 9 and 5k−4=215k - 4 = 21 are two of the six exceptions. The other four — 3131, 4343, 5555 and 8989 — exist because the pentagonal numbers are packed more tightly at the start than those of larger polygons, and a few more small gaps survive. The pentagon is the transition case: the first polygon whose exceptions are finite, and the last whose exceptions are irregular.

How Cauchy proved it

Cauchy’s proof reduces every polygon to a statement about squares.

The key identity is that 8(k−2)Pk(m)+(k−4)28(k-2)P_k(m) + (k-4)^2 is a perfect square: (2(k−2)m−(k−4))2\big(2(k-2)m - (k-4)\big)^2. So representing a number NN as a sum of kk-gonal numbers is equivalent to representing a related number as a sum of squares with a condition on the numbers being squared. Cauchy’s lemma — that for odd aa and bb with b2<4ab^2 < 4a and 3a<b2+2b+43a < b^2 + 2b + 4, there are four non-negative integers whose squares add to aa and which themselves add to bb — does the rest. The lemma handles the general kk with four squares and a controlled sum, and the remaining polygonal numbers in the count are ones and zeros used to adjust.

Melvyn Nathanson gave a short version of the proof in 1987, which fits on a page and explains why Fermat’s bound of kk is exactly what the lemma leaves room for: four terms from the lemma, and up to k−4k - 4 ones to correct the remainder. The bound is therefore not merely true but natural, and it is attained exactly for the small numbers the table shows.

Pentagons are squares in disguise

Cauchy’s identity is concrete enough to check by hand for pentagons. With k=5k = 5 it reads

24 P5(m)+1=(6m−1)2,24\,P_5(m) + 1 = (6m - 1)^2,

so every pentagonal number is ((6m−1)2−1)/24\big((6m-1)^2 - 1\big)/24. Writing a number NN as a sum of five pentagonal numbers is therefore the same as writing 24N+524N + 5 as a sum of five squares, each of a number that is one less than a multiple of six, with m=0m = 0 allowed to contribute a square of 11.

Take the last of the six exceptions, 8989. It is 1+1+1+35+511 + 1 + 1 + 35 + 51, five pentagonal numbers, and no fewer will do. On the other side of the identity, 24×89+5=2,14124 \times 89 + 5 = 2{,}141, and indeed 2,141=52+52+52+292+3522{,}141 = 5^2 + 5^2 + 5^2 + 29^2 + 35^2, five squares of numbers of the form 6m−16m - 1. The question about pentagons has become a question about squares with a congruence condition, and the theory of sums of squares is where every result about polygonal numbers is actually proved.

The same trick explains the six exceptions. A number that needs five pentagonal numbers is one for which 24N+524N + 5 cannot be written with fewer squares of the right kind — for small NN the right-kind squares, 1,25,121,289,…1, 25, 121, 289, \ldots, are too sparse to combine in fewer ways, and as NN grows they become dense enough that four, and then three, always do.

Pentagons with negative sides

Euler met the pentagonal numbers somewhere else entirely. Expanding the infinite product (1−x)(1−x2)(1−x3)⋯(1 - x)(1 - x^2)(1 - x^3)\cdots, he found that almost every coefficient cancels, and the survivors sit exactly at the exponents m(3m−1)/2m(3m-1)/2 — the pentagonal numbers — and the same formula at negative mm: 2,7,15,26,…2, 7, 15, 26, \ldots. The terms that cancel almost everything followed that cancellation.

Together, the values of m(3m−1)/2m(3m-1)/2 for all whole numbers mm, positive and negative, are the generalised pentagonal numbers: 0,1,2,5,7,12,15,22,26,…0, 1, 2, 5, 7, 12, 15, 22, 26, \ldots. With these, the pentagonal problem collapses: every number is a sum of three generalised pentagonal numbers, a fact that can be derived, with some care, from Gauss’s three-square theorem through the same identity, since allowing negative mm allows every number 6m−16m - 1 with either sign, and so every number not divisible by two or three. So the six stubborn exceptions of the ordinary pentagonal numbers are an artefact of forbidding the negative half of the family — the half that every partition hidden in a product needed to make its recurrence work.

Beyond the full count

Since only small numbers need all kk, a natural question is how many are needed by every large number. For pentagonal numbers the answer from computation is striking: numbers needing four become rarer and rarer — 114114 of them below a thousand, 8585 between a thousand and ten thousand, five between ten thousand and fifty thousand — and the last of them in a search to two hundred thousand is 33,06633{,}066. Beyond it, three pentagonal numbers appear to suffice. Richard Guy surveyed these questions in 1994 under the title “Every number is expressible as the sum of how many polygonal numbers?”, and the answers are known in some cases and conjectured in others.

The structure is the same as in the question of Waring for powers: g(k)g(k), the number needed for every number, is driven by small exceptions, while G(k)G(k), the number needed for all sufficiently large numbers, is smaller and much harder to determine. For polygonal numbers, Fermat’s claim is the gg; the GG is where the modern questions live.

What the grids and tables cannot show

The counts are exact up to twenty thousand. Each is the fewest polygonal numbers summing to the number, found by building the answers up from zero, so no number in the range is skipped and every stated exception is checked to be the only one in the range. Beyond twenty thousand, the claim that no further number needs all kk is a matter of proof, not of these figures.

Fermat’s claim is checked, not proved. The figures confirm that no number up to twenty thousand needs more than kk polygonal numbers of each kind; that none ever does is Cauchy’s theorem.

The pictures of dots are one arrangement of many. Polygonal numbers can be drawn centred rather than sharing a corner, which gives different numbers — the centred polygonal numbers — and a different set of questions.

Still open: whether three pentagons are enough after 33,066

The computations say that every number above 33,06633{,}066 is a sum of three pentagonal numbers, and they have been pushed far beyond the range drawn here without finding an exception. Whether it holds for every number is not known. The question has been asked since at least Richard Guy’s survey of 1994.

The difficulty is structural. Representing NN as a sum of three pentagonal numbers is, after Cauchy’s identity, representing a related number by a ternary quadratic form with conditions attached — and three-variable forms are exactly where the theory of representations stops being complete. For four variables, a finite check decides everything, as fifteen numbers decide every number describes. For three variables there can be sporadic exceptions scattered arbitrarily far out, and proving that a list of exceptions is finite and complete requires controlling them all. The same obstacle appears in Ramanujan’s form x2+y2+10z2x^2 + y^2 + 10z^2, whose odd exceptions are believed to end at 2,7192{,}719 and are proved to only on the assumption of a generalised Riemann hypothesis.

A bound that is sharp only at the start

The habit worth keeping is to ask where a bound is attained.

Fermat’s claim is sharp: kk polygonal numbers are needed, sometimes. For triangles and squares, sometimes means infinitely often, because a congruence forces it. For every larger polygon, sometimes means a handful of small numbers, forced by the gap between 11 and the next polygonal number. The contrast is sharpest between four sides and five. A square number bound of four is forced forever by arithmetic modulo eight; a pentagonal bound of five is forced by nothing but the crowding of the first few pentagonal numbers, and it lapses for good at eighty-nine. The theorem is the same for every polygon, and its truth is completely different in character once the polygon has five sides — a worst case that lives in the first ninety numbers and never recurs.

What links here

Computed from the collection, not written here: the essays that point at this one.

Reads more easily once this is understood

Essays that name this one as worth reading first.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

Exhaustive searchFigurate numbersGnomonQuadratic formSum of squaresTriangular numbers