Number Theory

Fermat Primes and the Constructible Polygons

Discover why only five Fermat primes are known and how they decide which regular polygons a compass and straightedge can build.

Key takeaways

  • The Fermat numbers are Fₙ = 2^(2ⁿ) + 1, and the first five, for n = 0 to 4, are prime.
  • Fermat believed all of them were prime, but Euler showed in 1732 that 641 divides F₅.
  • A regular n-gon is constructible exactly when n is a power of 2 times a product of distinct Fermat primes.
  • No Fermat prime beyond 65,537 is known, and none has been ruled out for all larger indices.

A Fermat prime is a prime of the form 2 raised to a power of 2, plus 1. Only five are known: 3, 5, 17, 257 and 65,537. These five numbers settle an old geometric question, namely which regular polygons can be drawn exactly with an unmarked straightedge and a compass.

The answer, due to Gauss and Wantzel, is one of the most surprising bridges in mathematics. Whether you can draw a 17-sided figure turns out to depend on a fact about prime numbers.

The numbers themselves

Raise 2 to a power of 2, then add 1.

F₀ = 2¹ + 1   = 3
F₁ = 2² + 1   = 5
F₂ = 2⁴ + 1   = 17
F₃ = 2⁸ + 1   = 257
F₄ = 2¹⁶ + 1  = 65,537
F₅ = 2³² + 1  = 4,294,967,297

Why use only powers of 2 in the exponent? Because 2ᵐ + 1 cannot be prime otherwise. Suppose m has an odd factor k greater than 1, with m = a × k. For odd k, the expression xᵏ + 1 factors as (x + 1)(xᵏ⁻¹ − xᵏ⁻² + ... − x + 1). Taking x = 2ᵃ shows that 2ᵃ + 1 divides 2ᵐ + 1.

For example, 2⁶ + 1 = 65 is divisible by 2² + 1 = 5. So any prime of the form 2ᵐ + 1, with m at least 1, must have m equal to a power of 2.

Fermat's guess and Euler's factor

Pierre de Fermat, writing in the 1600s, expressed confidence that every number of this form is prime. The first five support him. In 1732 Leonhard Euler broke the pattern.

F₅ = 4,294,967,297 = 641 × 6,700,417

Euler did not simply try every prime. One can show that any prime factor of Fₙ must leave remainder 1 when divided by 2ⁿ⁺¹, and for n at least 2, when divided by 2ⁿ⁺². For F₅ that means candidates of the form 128k + 1: 257, 641, 769 and so on. The factor appears very quickly.

Since then, computers and clever theory have shown that every Fermat number from F₅ through F₃₂ is composite. For some of these, no factor has ever been written down; compositeness was established by a test. The numbers double in length at each step, so progress is slow.

A test made for Fermat numbers

Pépin's test, from 1877, decides the matter with one calculation. For n at least 1, Fₙ is prime exactly when 3 raised to the power (Fₙ − 1)/2 leaves remainder −1 on division by Fₙ.

F₁ = 5:    3² = 9,     9 ≡ −1 (mod 5)       prime
F₂ = 17:   3⁸ = 6561,  6561 = 386 × 17 − 1  prime

The calculation is just repeated squaring. It is closely related to quadratic residues, since it asks whether 3 is a square modulo Fₙ. More general methods are described in testing large numbers.

The construction problem

Greek geometers worked with two idealized tools. A straightedge draws a line through two points, and a compass draws a circle with a given center passing through a given point. No measuring marks are allowed.

With these you can build an equilateral triangle, a square, a regular pentagon and a regular 15-gon. You can also double the number of sides of any polygon you have, by bisecting its central angles. So 6, 8, 10, 12, 16 and 20 sides follow.

The heptagon, with 7 sides, and the enneagon, with 9, resisted every attempt. For about two thousand years no new type of constructible polygon was found.

Gauss and the 17-gon

In 1796 the 18-year-old Carl Friedrich Gauss showed that the regular 17-gon can be constructed. He did it with algebra: the cosine of 360°/17 can be written using only whole numbers, the four arithmetic operations and square roots.

That is the key principle. Lines and circles have equations of degree 1 and 2, so intersecting them only ever requires solving linear and quadratic equations. A length is constructible from a unit length exactly when it can be reached through a finite chain of arithmetic and square roots.

The pentagon shows the idea in a small case.

cos 72° = (√5 − 1) / 4 ≈ 0.3090

Only one square root is needed. For 17 sides the formula involves square roots nested several layers deep.

Why a Fermat prime is exactly what is needed

Picture the corners of a regular p-gon, for a prime p, as the solutions of xᵖ = 1 in the complex plane. One solution is 1 itself. The other p − 1 solutions satisfy the polynomial xᵖ⁻¹ + ... + x + 1 = 0, which cannot be factored further over the rational numbers.

So building a corner means solving an equation of degree p − 1 that does not break apart. With square roots, you can only climb in doubling steps. That works when p − 1 is a power of 2, meaning p is a power of 2 plus 1. As shown above, such a prime has to be a Fermat prime.

Gauss's achievement was the other direction: when p − 1 is a power of 2, the equation really can be unraveled into a chain of quadratics. His method sorts the 16 non-trivial corners of the 17-gon into two groups of 8, then each group into two of 4, then 2, then single points.

The sorting uses powers of 3 modulo 17. Successive powers of 3 run through all 16 nonzero remainders before repeating, which makes 3 what is called a primitive root. Taking every second item in that list gives the first split. Each group sum then satisfies a quadratic whose coefficients are known from the step before.

The pentagon split

The same method on 5 sides is small enough to follow. Let c₁ be twice the cosine of 72° and c₂ twice the cosine of 144°. The five corners of a regular pentagon centered at the origin balance out, so their horizontal positions add to zero. That gives c₁ + c₂ = −1.

The product identity for cosines gives c₁ × c₂ = c₁ + c₂ = −1. Two numbers with a known sum and product are the roots of a quadratic.

t² + t − 1 = 0
t = (−1 ± √5) / 2
c₁ = (−1 + √5) / 2,  so cos 72° = (√5 − 1) / 4

The number c₁ is the reciprocal of the golden ratio, which explains why that ratio shows up throughout the pentagon.

The Gauss-Wantzel theorem

Gauss stated the general criterion, and in 1837 Pierre Wantzel supplied a proof that no other cases are possible.

A regular polygon with n sides (n ≥ 3) is constructible exactly when n is a power of 2 multiplied by a product of zero or more different Fermat primes.

The power of 2 can be 1. The Fermat primes must be distinct: 9 = 3 × 3 is excluded because 3 repeats.

sides n factorization constructible?
7 7 no, 7 is not a Fermat prime
9 3 × 3 no, 3 is repeated
12 4 × 3 yes
14 2 × 7 no
15 3 × 5 yes
17 17 yes
18 2 × 9 no
20 4 × 5 yes

An equivalent phrasing uses Euler's totient function: the n-gon is constructible exactly when φ(n) is a power of 2.

Is the regular n-gon constructible?
1 Strip the twos Divide n by 2 until the result is odd 2 Factor what is left Find its prime factors 3 Check each factor Each must be a Fermat prime and appear only once 4 Decide If all pass, compass and straightedge suffice Strip the twos Divide n by 2 until the result is odd 1 Factor what is left Find its prime factors 2 Check each factor Each must be a Fermat prime and appear only once 3 Decide If all pass, compass and straightedge suffice 4

Why the heptagon fails

The cosine of 360°/7 satisfies a cubic equation.

8x³ + 4x² − 4x − 1 = 0,   with x = cos(360°/7) ≈ 0.6235

This cubic cannot be factored into simpler pieces with rational coefficients. A number that satisfies such an irreducible cubic cannot be built from square roots alone, because chains of square roots only produce numbers whose minimal equations have degree 1, 2, 4, 8 and so on. Degree 3 does not fit.

The same style of argument disposes of two other ancient problems, covered in trisecting angles and doubling cubes. "Impossible" here is a proved statement about these two tools. With a marked ruler or paper folding, the heptagon can be constructed.

Constructible in theory, drawn in practice

The theorem concerns exact constructions with ideal tools. It does not promise that the construction is short or that a drawing on paper will look accurate. Explicit procedures for the 257-gon were published in the 1800s, and Johann Gustav Hermes is reported to have spent about ten years on the 65,537-gon.

At those sizes the figure is indistinguishable from a circle to the eye. Its interest is logical: the existence of the construction follows from the arithmetic of one prime.

You can also combine constructions. To get 15 sides, note that 2/5 of a full turn minus 1/3 of a full turn equals 1/15 of a turn. If you can mark off a fifth and a third on the same circle, their difference gives the side of the 15-gon. The same trick works for any two constructible polygons whose side counts share no factor, using Bezout's identity to find the right multiples.

2/5 − 1/3 = 6/15 − 5/15 = 1/15

The trick does not work for 9 from 3 and 3, because the two numbers are not coprime. No combination of thirds ever yields a ninth.

Are there more Fermat primes?

Nobody knows. A rough heuristic uses the prime number theorem: a number the size of Fₙ has a chance of being prime that is roughly proportional to 1/2ⁿ. Adding these small chances over all larger n gives a small total, which hints that there may be no more at all. Fermat numbers are far from random, so treat this as a guess.

If the known five are the only ones, then there are exactly 31 odd numbers of sides, greater than 1, for which construction works: the products of one or more of 3, 5, 17, 257 and 65,537. The largest is the product of all five.

3 × 5 × 17 × 257 × 65,537 = 4,294,967,295 = 2³² − 1

That tidy value comes from the identity F₀ × F₁ × ... × Fₙ₋₁ = Fₙ − 2. It also shows that no two Fermat numbers share a factor, which gives another proof that there are infinitely many primes: each Fermat number brings at least one prime not seen before.

Written for 4Mathematics with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 59 articles in Number Theory →

Latest news on this topic