Fermat Numbers (Important Theorems & Examples)
Fermat was convinced he’d found an infinite source of prime numbers. He was wrong. Here’s the fascinating story of Fermat Numbers—and why one of history’s greatest mathematicians got fooled by a pattern that breaks down spectacularly.

What Are Fermat Numbers?
Fermat Numbers are integers of the form:
$$ F_n = 2^{2^n} + 1 \quad \text{where } n \geq 0 $$
Notice the structure: it’s not just \( 2^n + 1 \). The exponent itself is a power of 2. This double-exponential growth means Fermat numbers get enormous incredibly fast.
Let’s calculate the first few:
| \( n \) | Calculation | \( F_n \) | Prime? |
|---|---|---|---|
| 0 | \( 2^{2^0} + 1 = 2^1 + 1 \) | 3 | ✓ Yes |
| 1 | \( 2^{2^1} + 1 = 2^2 + 1 \) | 5 | ✓ Yes |
| 2 | \( 2^{2^2} + 1 = 2^4 + 1 \) | 17 | ✓ Yes |
| 3 | \( 2^{2^3} + 1 = 2^8 + 1 \) | 257 | ✓ Yes |
| 4 | \( 2^{2^4} + 1 = 2^{16} + 1 \) | 65,537 | ✓ Yes |
| 5 | \( 2^{2^5} + 1 = 2^{32} + 1 \) | 4,294,967,297 | ✗ No |
See that pattern? The first five Fermat numbers are all prime. Fermat saw this too—and made a bold claim that would haunt his legacy.
Fermat’s Conjecture (And Why It Failed)
Pierre de Fermat examined \( F_0 \) through \( F_4 \), found them all prime, and made a confident announcement. In a letter to Marin Mersenne, he declared:
“I have found that numbers of the form \( 2^{2^n} + 1 \) are always prime numbers and have long since signified to analysts the truth of this theorem.”
Here’s the thing: Fermat admitted he couldn’t actually prove it. He’d checked five cases and assumed the pattern would continue forever.
It didn’t.
In 1732—nearly a century after Fermat’s death—Leonhard Euler demolished the conjecture. He proved that \( F_5 = 4,294,967,297 \) is divisible by 641.
The lesson? In mathematics, five examples aren’t proof. Even a million examples aren’t proof. You need rigorous demonstration—or a single counterexample to destroy a conjecture entirely.
Proving \( F_5 \) is Composite: Bennett’s Elegant Proof
The elementary proof that \( 641 \mid F_5 \) is due to G. Bennett. It’s a beautiful piece of algebraic manipulation that requires no computers—just clever factoring.
Goal: Show that \( F_5 = 2^{32} + 1 \) is divisible by 641.
Step 1: Set up the key variables
Let \( a = 5 \) and \( b = 2^7 = 128 \).
Notice that:
- \( ab + 1 = 5 \times 128 + 1 = 641 \) ✓
- \( a^4 = 5^4 = 625 \)
Step 2: Find a useful identity
Subtract \( a^4 \) from 641:
$$ ab + 1 – a^4 = 641 – 625 = 16 = 2^4 $$
This gives us: \( 2^4 = 1 + ab – a^4 \)
Step 3: Rewrite \( F_5 \) using our variables
$$ F_5 = 2^{32} + 1 = 2^4 \cdot (2^7)^4 + 1 = 2^4 \cdot b^4 + 1 $$
Step 4: Substitute and factor
Replacing \( 2^4 \) with our identity:
$$ F_5 = (1 + ab – a^4) b^4 + 1 $$
After algebraic manipulation (expanding and regrouping), this factors as:
$$ F_5 = (1 + ab) \cdot \left[ a^4 + (1 – ab)(1 + a^2 b^2) \right] $$
Since \( 1 + ab = 641 \), we have:
$$ F_5 = 641 \times (\text{an integer}) $$
Therefore, \( 641 \mid F_5 \). QED. ∎
Pro Tip: The other factor is 6,700,417. So \( F_5 = 641 \times 6,700,417 \). Both factors are prime, making this the complete factorization.
Key Properties of Fermat Numbers
Fermat numbers have several remarkable properties that make them interesting beyond the primality question.
Property 1: Fermat Numbers Are Mutually Coprime
For any two Fermat numbers \( F_m \) and \( F_n \) with \( m > n \geq 0 \):
$$ \gcd(F_m, F_n) = 1 $$
This means no two Fermat numbers share a common factor. Here’s why this matters: it provides an elegant proof that there are infinitely many primes (each Fermat number must have at least one prime factor not shared by any other).
Property 2: Recursive Relationship
Fermat numbers satisfy a beautiful recursive formula:
$$ F_n = F_0 \cdot F_1 \cdot F_2 \cdots F_{n-1} + 2 $$
This identity is key to proving the mutual coprimality property above.
Property 3: Connection to Constructible Polygons
Gauss proved that a regular \( n \)-gon is constructible with compass and straightedge if and only if \( n \) is a power of 2 times a product of distinct Fermat primes.
Since only \( F_0 = 3 \), \( F_1 = 5 \), \( F_2 = 17 \), \( F_3 = 257 \), and \( F_4 = 65537 \) are known to be prime, constructible odd-sided polygons are surprisingly rare.
Primality Tests for Fermat Numbers
Two powerful theorems help determine whether a Fermat number is prime:
Pépin’s Test (1877)
For \( n \geq 1 \), the Fermat number \( F_n \) is prime if and only if:
$$ 3^{(F_n – 1)/2} \equiv -1 \pmod{F_n} $$
This is a complete characterization—not just a necessary condition, but sufficient as well. The 3 can be replaced by any quadratic non-residue modulo \( F_n \).
Euler–Lucas Theorem
Any prime divisor \( p \) of \( F_n \) (where \( n \geq 2 \)) must have the form:
$$ p = k \cdot 2^{n+2} + 1 $$
for some positive integer \( k \).
This dramatically narrows the search space when hunting for factors. For \( F_5 \), we’d only need to check primes of the form \( 128k + 1 \). Indeed, \( 641 = 5 \times 128 + 1 \) fits this pattern.
Current State of Knowledge
After centuries of investigation, here’s what we know about Fermat numbers:
| Status | Values of \( n \) |
|---|---|
| Confirmed Prime | 0, 1, 2, 3, 4 |
| Completely Factored | 5, 6, 7, 8, 9, 10, 11 |
| Two or More Factors Known | 12, 13, 15, 16, 18, 19, 25, 27, 30, and others |
| One Prime Factor Known | 14, 17, 20, 21, 22, 23, 24, and many more |
| Composite, No Factors Known | Several large \( n \) values proven composite via Pépin’s test |
The big open questions: Are there infinitely many Fermat primes? Or are there only five? Most mathematicians conjecture that \( F_0, F_1, F_2, F_3, F_4 \) are the only Fermat primes—but nobody has proven this.
Why Fermat Numbers Matter
Beyond pure mathematical curiosity, Fermat numbers appear in several important contexts:
- Cryptography: The structure of Fermat numbers relates to fast modular exponentiation
- Number Theory: They provide examples and counterexamples for primality conjectures
- Geometry: Fermat primes determine which regular polygons are constructible
- Computer Science: The number-theoretic transform uses Fermat primes for efficient convolution
Frequently Asked Questions
What is the difference between Fermat numbers and Fermat primes?
A Fermat number is any number of the form 2^(2^n) + 1. A Fermat prime is a Fermat number that happens to be prime. All Fermat primes are Fermat numbers, but not all Fermat numbers are prime. Only five Fermat primes are currently known: 3, 5, 17, 257, and 65537.
Why was Fermat wrong about his conjecture?
Fermat checked only the first five Fermat numbers (F₀ through F₄), found them all prime, and assumed the pattern continued. But F₅ is composite—it equals 641 × 6,700,417. This is a classic example of how pattern recognition can fail in mathematics: five examples, no matter how convincing, don’t constitute a proof.
How did Euler factor F₅ without a computer?
Euler knew that any prime factor of F₅ must have the form 64k + 1 (a result he derived from number theory). This narrowed the search significantly. He then tested candidates systematically until finding that 641 divides F₅. The elementary proof by Bennett, shown in this article, uses clever algebraic identities to demonstrate this without exhaustive division.
Are there infinitely many Fermat primes?
This remains one of the major unsolved problems in number theory. Most mathematicians conjecture that there are only five Fermat primes (F₀ through F₄), but this hasn’t been proven. Despite extensive computational searches, no Fermat prime beyond F₄ = 65537 has ever been found.
What is Pépin’s test used for?
Pépin’s test is a primality test specifically for Fermat numbers. It states that F_n (for n ≥ 1) is prime if and only if 3^((F_n-1)/2) ≡ -1 (mod F_n). This test can prove a Fermat number is composite even when we can’t find its factors—we just compute the modular exponentiation and check the result.
Why do Fermat primes matter for geometry?
Gauss proved that a regular n-sided polygon is constructible with compass and straightedge if and only if n is a power of 2, or a power of 2 multiplied by distinct Fermat primes. Since only five Fermat primes are known, this severely limits which regular polygons can be constructed classically. For example, a regular 17-gon is constructible (17 is a Fermat prime), but a regular 7-gon is not.
The Bottom Line
Fermat numbers are a perfect case study in mathematical humility. One of history’s greatest mathematicians looked at five examples and declared a universal truth—only to be proven wrong by an even greater mathematician a century later.
The irony? Despite knowing that Fermat was wrong about infinitely many Fermat primes, we still can’t prove the opposite. Whether \( F_0 \) through \( F_4 \) are the only Fermat primes remains one of number theory’s tantalizing open questions.
That’s mathematics for you: sometimes the questions outlive the questioners by centuries.