# Pépin's test

## Introduction

Pépin's test is mainly used for proving the primality of Fermat numbers, but it is of no help for finding the factors of such numbers.

Pépin's test has been proven by French Father Pépin in 1877.

In his famous book about Édouard Lucas (page 101), HC Williams says: "The test that we today call Pépin's test is actually Proth's test with a proof provided by Lucas".

Pépin's test can also be used for proving the primality of other numbers, like the Generalized Fermat numbers $F_{n,2} = 4^{3^n}+2^{3^n}+1$ with k = 5 instead of k = 3.

## The Maths

Pépin's test says: If $n\gt 0$, $F_n = 2^{2^n}+1$ is a prime if and only if $\ 3^{(F_n-1)/2} \ \equiv -1 \ \pmod{F_n}$.

## Bits of history

Pépin found the following:

If $F_n = 2^{2^n}+1$, then $F_n$ is a prime if and only if $\ 5^{(F_n-1)/2} \equiv -1 \ \pmod{F_n}$.

Then Lucas noticed that any number a can be used instead of 5 if $\left({a \atop {F_n}}\right) = -1$, where $\left({a \atop p}\right)$ is the Jacobi symbol.

Proth in 1878 mentioned the use of 3 but was unable to provide a complete proof, but Lucas later supplied him with one.

Pépin also noted that this test can also be made into a simple Lucas-like test by defining $T_i=5^2$ and $T_{i+1}=T_i^2$.

$\ F_n$ is a prime if and only if $F_n \ \mid \ T_{2^n-1}+1$.

And Lucas pointed out that the proof of sufficiency of Pépin's test followed from his fundamental theorem, with $\alpha = 5 \ , \ \beta = 1$.

The Fermat numbers $\ F_7$, $\ F_8$, $\ F_{13}$, $\ F_{14}$, $\ F_{17}$, $\ F_{20}$, $\ F_{22}$, $\ F_{24}$ and $\ F_{28}$ were all originally proven composite by versions of Pépin's test. At present, there are still no known factors of $\ F_{20}$, and $\ F_{24}$. The smallest Fermat number with unknown primality status is the enormous $\ F_{33}$ with 2,585,827,973 decimal digits. Unfortunately, performing Pépin's test on this number on our fastest computers would take centuries to run to completion!