Fermat number (source code)

= Fermat number
{c}
{title2=$F_n=2^{2^n}+1$}
{wiki}

A <Fermat number> is the <positive integer> $F_n=2^{2^n}+1$, indexed by a <nonnegative integer> $n$. The first five are $3,5,17,257,65537$, all <prime numbers>; the next is \b[the <composite number> $F_5=4294967297=641\cdot6700417$]. This family offers a compact lesson in <number theory>: a very persuasive finite pattern can fail, while an exact <divisibility> relation settles a gigantic case with little computation.

\Image[/fermat-numbers-growth-and-first-factors.png]
{title=Exact Fermat numbers: five initial primes, a composite sixth term, and rapidly increasing decimal lengths}

Why does the exponent itself have the form $2^n$? Suppose $m=ab$ is a <positive integer> with an <odd integer> factor $b>1$. The <polynomial factorization> $x^b+1=(x+1)(x^{b-1}-x^{b-2}+\cdots-x+1)$ shows that $2^a+1$ is a proper <divisor> of $2^m+1$. Consequently, if $2^m+1$ is a <prime number>, $m$ must be a <power of two>. That is a necessary condition, rather than a promise that the surviving candidates are prime.

The <Fermat number product identity> makes distinct <Fermat numbers> <coprime integers>. Thus every term has a <prime factor> absent from all earlier terms, whether or not that term is itself a <prime number>. This gives an explicit route to infinitely many different <prime numbers>, without establishing that infinitely many terms of this particular <sequence> are prime. Meanwhile the <prime divisor of a Fermat number> criterion filters possible factors through a small <multiplicative order> calculation.

The family also links arithmetic to <Euclidean geometry>: a <constructible regular polygon> can have a number of sides equal to a <power of two> times a product of distinct <Fermat primes>. The <Gauss-Wantzel theorem> gives the precise criterion. For instance, $15=3\cdot5$ and $17$ qualify, but $9=3^2$ does not. The word "distinct" matters. <Carl Pomerance> describes this connection in <Primality testing: then and now by Carl Pomerance> (slide 18).

Historically, <Leonhard Euler> records <Pierre de Fermat>'s proposed primality pattern, then refutes it by finding the factor $641$ of $F_5$. His paper was presented in 1732 and published in 1738; those are different events, not competing dates for one publication.<Observations on a certain theorem of Fermat and on others concerning prime numbers by Leonhard Euler>[pp. 1–2 and the publication note]{ref}

A short modern check needs only two representations of $641$:
$$
641=5\cdot2^7+1=5^4+2^4.
$$
In <modular arithmetic> these give $5^4 2^{28}\equiv1$ and $5^4\equiv-2^4\pmod{641}$. Substitution yields $2^{32}\equiv-1\pmod{641}$, so $641\mid F_5$. This verifies the factor directly; it does not claim to reconstruct Euler's search process.