Mathwords logoMathwords

Fermat Number — Definition, Formula & Examples

A Fermat number is a positive integer of the form 22n+12^{2^n} + 1, where nn is a non-negative integer. The first few Fermat numbers are 3, 5, 17, 257, and 65537.

For each non-negative integer nn, the nn-th Fermat number is defined as Fn=22n+1F_n = 2^{2^n} + 1. A Fermat number that is also prime is called a Fermat prime. As of today, the only known Fermat primes are F0F_0 through F4F_4.

Key Formula

Fn=22n+1F_n = 2^{2^n} + 1
Where:
  • nn = A non-negative integer (0, 1, 2, 3, ...)
  • FnF_n = The n-th Fermat number

How It Works

To find the nn-th Fermat number, first compute the exponent 2n2^n, then raise 2 to that power and add 1. Fermat conjectured that every number of this form is prime, but Euler disproved this in 1732 by showing F5=4,294,967,297F_5 = 4{,}294{,}967{,}297 is divisible by 641. No Fermat primes beyond F4=65,537F_4 = 65{,}537 have been found, and it remains an open question whether infinitely many Fermat primes exist.

Worked Example

Problem: Compute the Fermat numbers F_0 through F_4.
F_0: Set n = 0. Compute the exponent 2^0 = 1, then 2^1 + 1.
F0=220+1=21+1=3F_0 = 2^{2^0} + 1 = 2^1 + 1 = 3
F_1: Set n = 1. The exponent is 2^1 = 2, so compute 2^2 + 1.
F1=221+1=22+1=5F_1 = 2^{2^1} + 1 = 2^2 + 1 = 5
F_2: Set n = 2. The exponent is 2^2 = 4.
F2=24+1=17F_2 = 2^{4} + 1 = 17
F_3: Set n = 3. The exponent is 2^3 = 8.
F3=28+1=257F_3 = 2^{8} + 1 = 257
F_4: Set n = 4. The exponent is 2^4 = 16.
F4=216+1=65,537F_4 = 2^{16} + 1 = 65{,}537
Answer: The first five Fermat numbers are 3, 5, 17, 257, and 65,537. All five are prime.

Why It Matters

Fermat primes are directly connected to classical geometry: Gauss proved that a regular polygon with nn sides can be constructed using only a compass and straightedge if and only if nn is a power of 2 times a product of distinct Fermat primes. Fermat numbers also appear in algorithms and primality testing within number theory courses.

Common Mistakes

Mistake: Confusing 22n+12^{2^n} + 1 with 22n+12^{2n} + 1. For example, writing F3=26+1=65F_3 = 2^6 + 1 = 65 instead of 28+1=2572^8 + 1 = 257.
Correction: The exponent itself is 2n2^n, not 2n2n. Compute the tower of exponents from the top down: first evaluate 2n2^n, then use that result as the exponent of 2.