Danny Siu's Personal Blog

Using Fermat Number to prove the infinity of primes

April 19, 2020 | 2 min read

What is Fermat Number?

Fermat number is defined as 22n+12^{2^n}+1 (named after Pierre de Fermat) where nn is a non-negative integer. The first five Fermat numbers are 3,5,17,2573, 5, 17, 257 and 6553765537. We denote F(n)=22n+1F(n) = 2^{2^n}+1 for convenience. So,

F(0)=220+1=3F(1)=221+1=5F(2)=222+1=17F(3)=223+1=257F(4)=224+1=65537\begin{aligned} F(0) &= 2^{2^0}+1 = 3\\ F(1) &= 2^{2^1}+1 = 5\\ F(2) &= 2^{2^2}+1 = 17\\ F(3) &= 2^{2^3}+1 = 257\\ F(4) &= 2^{2^4}+1 = 65537\\ \end{aligned}

Lemma 1: F(m)2F(m)−2 is divisible by F(n)F(n) if m>nm > n.

Proof:

F(m)2F(m)−2 =22m1= 2^{2^m}−1 =(22m1+1)×(22m11)= ({2^{2^{m−1}}+1})×({2^{2^{m−1}}−1}) =F(m1)×(F(m1)2)=F(m−1)×\Big(F(m−1)−2\Big)

Similarly, F(m1)2=F(m2)×(F(m2)2)F(m−1)−2 = F(m−2)×\Big(F(m−2)−2\Big). Hence, we can deduce that

F(m)2=F(m1)×(F(m1)2)=F(m1)×F(m2)×(F(m2)2)=F(m1)×F(m2)××F(n)×(F(n)2)\begin{aligned} &F(m)−2\\ &=F(m−1)×\Big(F(m−1)−2\Big)\\ &=F(m−1)×F(m−2)×\Big(F(m−2)−2\Big)\\ &⋮\\ &=F(m−1)×F(m−2)×⋯×F(n)×\Big(F(n)−2\Big)\\ \end{aligned}

So, F(m)2F(m)−2 is divisible by F(n)F(n) if m>nm > n.

Lemma 2: F(m)F(m) and F(n)F(n) are relatively prime if mnm \ne n. (That means their greatest common divisor is 11)

Proof:

Assume m>nm > n, and let gg be the greatest common divisor of F(m)F(m) and F(n)F(n). So, gF(m)g|F(m) and gF(n)g|F(n)

(gF(m)g|F(m) means gg divides F(m)F(m) OR F(m)F(m) is divisible by gg)

The fact that gF(n)g|F(n) and by lemma 1, F(n)(F(m)2)F(n)|\Big(F(m)−2\Big), g(F(m)2)g|\Big(F(m)−2\Big) So, g(F(m)(F(m)2))g|\bigg(F(m)−\Big(F(m)−2\Big)\bigg) and thus g2g|2 i.e. g=1g = 1 or 22 But all Fermat numbers are odd, therefore gg must be 11. Hence, F(m)F(m) and F(n)F(n) are relatively prime if mm is not equal to nn.

Final deduction

Now, to prove the infinity of primes, we keep generating Fermat numbers F(n)F(n). If F(n)F(n) is prime, we have a new prime number. If F(n)F(n) is composite, then it has a prime factor which never exists before since all distinct Fermat numbers are relatively prime (by lemma 2). As we can generate as many Fermat numbers as we want by simply substituting different values of nn, so the number of primes is infinite.


Written by Danny Siu who lives in Hong Kong. You should follow him on Twitter