A Fermat number is of the form where
is a nonnegative integer. A Fermat prime is a Fermat number that is a prime number. The first five Fermat numbers
to
are known to be prime. Pierre de Fermat (1601-1665) conjectured that all Fermat numbers are prime. In 1732, Euler discovered a counterexample by showing that
is composite with
. The challenge for working with Fermat numbers is that the numbers grow very rapidly. However, Fermat numbers have many interesting properties. See here for a more detailed look. In this post, we discuss Pepin’s test, which is a primality test solely for Fermat numbers, as well as a sequence of integers that are associated with Fermat numbers. Out of this sequence of integers comes the notion of elite prime numbers.
The following are two versions of the Pepin’s test. Theorem 1 is proved in this previous post.
Theorem 1 (Pepin’s Test)
For any , the Fermat number
is a prime number if and only if
.
Theorem 2 (Pepin’s Test)
For any , the Fermat number
is a prime number if and only if
.
To determine whether a Fermat number is prime, simply raise 3 (or 5) to the exponent of
modulo
. If the result is congruent to -1, then
is prime. Otherwise it is composite. The exponentiation can be performed using the fast powering algorithm (also called square-and-multiply). The idea is to use the binary expansion of the exponent to convert the exponentiation into a series of squarings and multiplications. For Pepin’s test, the exponent is a power of 2. Thus the binary expansion is a 1 followed by a number of zeros. As a result, in programming the “square-and-multiply”, we only need to program the squarings.
The above two versions of Pepin’s test use 3 and 5 as bases. An interesting and natural question arises. What are all the numbers that can serve as bases for the Pepin’s test? In fact, there are many other bases. What would be the property that unites all the possible bases? The sequence A129802 in OEIS describes all possible bases for use in Pepin’s test. In this post, we give a formulation of Pepin’s test that takes into account all the possible bases in this sequence. We also discuss the prime numbers in the sequence, which are also captured in the sequence A102742 (these are called elite prime numbers).
___________________________________________________________________
The Periodic Nature of Fermat Numbers
Let be any positive integer with
. Consider all Fermat numbers
reduced modulo
, i.e.
. We call these values the Fermat remainders modulo
. Since there are only
many such values, i.e.
and since Fermat numbers can be derived by the recursive formula
the Fermat remainders are periodic. Let’s look at an example.
Let . The following shows the first several Fermat remainders modulo 41. Each value is computed from the previous value via the recursive relation
, which is then reduced modulo 41.
It is clear the Fermat remainders 17, 11, 19, 38 repeat themselves as increases. For Fermat remainders modulo 41, the periodicity starts at
and the length of the period is 4 (we call this the Fermat period).
Let’s describe idea behind the example more generally. Because any Fermat remainder must be an element of , there exist at least two Fermat numbers sharing the same remainder, say
and
with
. Assume that
and
are the smallest possible choices. In the modulo 41 example,
would be 2 and
would be 6. As a result,
is the starting point of the period and
is the length of the Fermat period.
Based on the discussion in the above paragraph, for any positive integer , the Fermat remainders modulo
are periodic with the repeating remainders starting at some Fermat number
. The length of the Fermat period is the smallest positive integer
satisfying the congruence
for all
and for all positive integer
.
The symbol is a Legendre symbol if the bottom number is a prime number, in which case the value of the symbol is 1 or -1. If the bottom number is a composite number, then it is a Jacobi symbol with possible values 0, 1 or -1.
We now wish to evaluate the symbol where the bottom part is a Fermat number and the top part is a possible base for Pepin’s test. Consider the following derivation.
The first Jacobi symbol can be flipped without changing sign because for all
. This is due to the law of quadratic reciprocity of Jacobi symbol (see bullet # 6 in Theorem 6 here). The number
in the top part of the third Jacobi symbol represents all the possible Fermat remainders modulo
. For example, if
,
would be 17, 11, 19 or 38. The above relation in Jacobi symbol is how we tie Fermat remainders with the Pepin’s test.
___________________________________________________________________
The Sequences
The following theorem gives the linkage between Fermat remainders and the Pepin’s test.
Theorem 3
Let be a positive integer where
. The following conditions are equivalent.
- The Jacobi symbol
for all Fermat remainders
modulo
.
- There is a positive integer
such that the Jacobi symbol
for all
.
Proof of Theorem 3
Note that if condition 1 is not true, then there is one Fermat remainder such that the Jacobi symbol
. Since the Fermat remainders are periodic, via relation
above there are infinitely many
with
. Thus condition 2 is not true. In other words,
holds. On the other hand, if condition 2 is not true, then condition 1 is not true.
Any positive integer belongs to the sequence A129802 if and only of one of the conditions in Theorem 1 holds. Note that 2 does not belong to the sequence. To see this, note that
for all
. So there is only one Fermat remainder modulo 2, namely 1. Since the Legendre symbol
, condition 1 in Theorem 1 is not true. Thus all possible members of the sequence A129802 must be 3 or higher. The numbers 3 and 5 both belong to the sequence. Both numbers have only one Fermat remainder, namely 2. Note that
for all
and
for all
. Also note that the Legendre symbols
and
.
What if we limit the scope of Theorem 3 to just the prime numbers? The following is the translation of Theorem 3 where is a prime number (using
to replace
).
Theorem 4a
Let be a prime number. The following conditions are equivalent.
- The Legendre symbol
for all Fermat remainders
modulo
.
- There is a positive integer
such that the Legendre symbol
for all
.
Condition 2 of Theorem 4a should start with the Jacobi symbol . Since it can be flipped without changing sign, it become the Legendre symbol
. Next, the following theorem is obtained by rewriting Theorem 4a using the meaning of the Legendre symbol.
Theorem 4b
Let be a prime number. The following conditions are equivalent.
- For each Fermat remainders
modulo
,
is a quadratic nonresidue modulo
- For each Fermat remainders
modulo
, the congruence
holds.
- There is a positive integer
such that the Fermat number
is a quadratic nonresidue modulo
for all
.
Note that condition 2 in Theorem 4b is due to Euler’s criterion.
Any prime number that satisfies any one of the conditions in Theorem 4b is said to be an elite prime number. Thus an elite prime can be used as a base for the Pepin’s test and is a member of the sequence A129802. In fact, another sequence A102742 is to capture all the elite prime numbers.
Note that 3 and 5 are elite primes as is the prime number 41. The Fermat remainders modulo 41 are 17, 11, 19 and 38 (as shown above). All of the 4 Fermat remainders are quadratic nonresidue modulo 41. The Legendre symbols have value -1 as shown below:
Before further discussing elite primes, let’s have a more general statement of Pepin’s test.
___________________________________________________________________
Pepin’s Test – General Version
Theorem 5 (Pepin’s Test)
Let be an integer such that there exists a positive integer
such that the Jacobi symbol
for all
. In other words,
is a member of the sequence A129802. Then for any
, the Fermat number
is a prime number if and only if
.
Proof of Theorem 5
Let be a number that satisfies the requirement in Theorem 5, i.e. it is a member of the sequence A129802. Let
. Suppose that
is prime. Then the symbol
is a Legendre symbol. By the Euler’s criterion, we have
.
Suppose that the congruence holds. Then by Lucas primality test,
is prime. For the details, see the proof of Theorem 7 in this previous post.
Theorem 5 is a version of Pepin’s test that takes into account of all the possibilities for a base. Any number in the sequence A129802 will work. This version is more interesting from a mathematical standpoint. In practice, to use Pepin’s test, we must first settle on a base. Pick a number from list of A129802 or find some number that satisfies one condition in Theorem 3. It is also important to determine the least number
for the condition in Theorem 3. The
is the lower bound for the
that can be tested by Pepin’s test. Of course, it is handy to use 3 or 5 as a base. Thus the versions such as Theorem 1 and Theorem 2 above are useful in practice. Mathematically Theorem 5 is more interesting. It brings out the concept of the integer sequence A129802 and the notion of elite prime.
___________________________________________________________________
More on the Sequences
There is one natural question about the A129802 (possible bases for Pepin’s test) and the sequence A102742 (possible prime bases for Pepin’s test, the elite primes). Does each sequence contain infinitely many numbers? The answer is not known for the second sequence (the elite primes). It is not known whether there are infinitely many elite primes. However, we can show that the first sequence infinitely many members.
Theorem 6
- If
is a member of the sequence A129802, then the number
is also a member of the sequence.
- If
is a member of the sequence A129802, then for any integer
, the number
is also a member of the sequence.
Proof of Theorem 6
We prove the first bullet point. The second follows from the first. Since is in the sequence A129802 (i.e. it satisfies Theorem 3), there is a least
such that
for all
. The following derivation shows that
for all
.
In the above derivation, a property of Jacobi symbol is used along with the fact that 1 is a quadratic residue modulo 2 and the fact that .
Since 3 is a base for Pepin’s test, 3, 6, 12, 24, 48, 96, … are also bases for Pepin’s test.
___________________________________________________________________
Elite Primes
From the perspective of Fermat numbers, elite prime numbers are simply prime numbers that can serve as bases for Pepin’s primality test for Fermat numbers. Of course this is not a good working definition. Theorem 5 tells us that any prime number that can work as a base for Pepin’s test satisfies the conditions in Theorem 4b (or 4a). Thus we can define elite primes by Theorem 4b. Any odd positive integer is an elite prime if it satisfies anyone of the conditions in Theorem 4b. We introduce the notion of elite prime by way of Pepin’s test of primality of Fermat numbers. Of course, it is possible to define the notion by using only the conditions in Theorem 4b.
As of the writing of this post, there are 29 known elite primes. The smallest are 3, 5, 7, 41, 15361, 23041, 26881, 61441, 87041. The largest is 3,580,135,407,617, about 3.58 trillion. According to the prime number theorem, there are approximately 124 billion prime numbers in this range. So elite primes are very sparse in the number line. No one know whether there are infinitely many elite primes.
How does one test whether a prime number is an elite prime? One way is to use Theorem 4b. Identify the Fermat remainders modulo the prime . Compute the congruence
for each remainder
. If
for all
, then
is an elite prime. it turns out that if
is indeed elite, the calculation to verify is quite light. If
is not elite, there usually is a Fermat remainder early on that disproves the eliteness. We close with two examples.
Example 1
Verify that the largest known elite prime 3,580,135,407,617 is indeed elite.
Let = 3,580,135,407,617. Then
54,628,531. This means that the period will start at or before
. The following shows the Fermat remainders.
The Fermat period starts at . The length of the period is 8 (the remainders are in bold). Let
denote the remainder of
. Now raise each remainder to the power of
modulo
. The following shows the results.
The calculation shows that each Fermat remainder is a quadratic nonresidue modulo 3,580,135,407,617. Thus it is an elite prime. .
Example 2
The next prime number beyond the elite prime in Example 1 is = 3,580,135,407,647. Show that it is not elite.
Note that = 2 x 1,790,067,703,823. Because the exponent in the power of 2 is 1, the period would begin at
or
. For some reason, the length of the Fermat period for a non-elite prime can be very long. The following shows the first 13 or 14 remainders.
Fortunately one of the early remainders disproves the eliteness. The following shows that calculation.
Even though the Fermat period may be very long in this case, there are several Fermat remainders early that show . This shows that the prime in this example cannot be elite.
The notion of elite primes is an interesting one. Even though the initial motivation is Pein’s test – a primality test for Fermat numbers, the notion of elite prime is interesting in its own right. There had been a lot of research done, both computationally and mathematically. See the references listed in the two OEIS sequences A129802 and A102742.
___________________________________________________________________
Let