Mersenne and Fermat Primes

Some primes come in special, beautiful shapes — one less than a power of two, or one more. These families, named for Marin Mersenne and Pierre de Fermat, have driven the hunt for record-breaking primes for centuries and connect surprisingly to perfect numbers and to geometry.

Mersenne primes: 2^n - 1

A Mersenne number is M_n = 2^n - 1; when it is prime we call it a Mersenne prime. The first few exponents that work are n = 2, 3, 5, 7, giving 3, 7, 31, 127.

A neat constraint cuts the search down: if 2^n - 1 is prime, then n must itself be prime. The reason is a factoring identity — if n = ab, then 2^a - 1 divides 2^n - 1:

2^{ab} - 1 = (2^a - 1)\big(2^{a(b-1)} + \dots + 2^a + 1\big).

The converse fails — 2^{11} - 1 = 2047 = 23 \times 89 even though 11 is prime — but it still means we only ever test prime exponents. The largest known primes are almost always Mersenne, because there is an especially fast test (Lucas–Lehmer) for exactly this form.

Fermat primes: 2^{2^k} + 1

A Fermat number is F_k = 2^{2^k} + 1. The first five are prime: 3, 5, 17, 257, 65537. Fermat conjectured they all were — and was spectacularly wrong. Euler factored the very next one:

F_5 = 2^{32} + 1 = 4294967297 = 641 \times 6700417.

In fact no Fermat prime beyond F_4 has ever been found. (Here the constraint runs the other way: 2^m + 1 can only be prime when the exponent m is itself a power of two.)

A startling bridge to geometry

Gauss proved that a regular polygon with N sides is constructible with straightedge and compass precisely when N is a power of two times a product of distinct Fermat primes. That is why the regular 17-gon can be drawn (and Gauss, aged 19, was so proud he asked for one on his tombstone) but the regular 7-gon cannot. Mersenne primes, meanwhile, generate every even perfect number — a link we will trace later.