Fermat's little theorem states that if p is prime and a is coprime to p, then ap−1 − 1 is divisible by p. For a positive integer a, if a composite integer x divides ax−1 − 1, then x is called a Fermat pseudoprime to base a.
[1]: Def. 3.32
In other words, a composite integer is a Fermat pseudoprime to base a if it successfully passes the Fermat primality test for the base a.[2] The false statement that all numbers that pass the Fermat primality test for base 2 are prime is called the Chinese hypothesis.
The smallest base-2 Fermat pseudoprime is 341. It is not a prime, since it equals 11·31, but it satisfies Fermat's little theorem: 2340 ≡ 1 (mod 341) and thus passes the
Fermat primality test for the base 2.
Pseudoprimes to base 2 are sometimes called Sarrus numbers, after P. F. Sarrus who discovered that 341 has this property, Poulet numbers, after P. Poulet who made a table of such numbers, or Fermatians (sequence A001567 in the OEIS).
A Fermat pseudoprime is often called a pseudoprime, with the modifier Fermat being understood.
An integer x that is a Fermat pseudoprime for all values of a that are coprime to x is called a Carmichael number.[2][1]: Def. 3.34
Properties
Distribution
There are infinitely many pseudoprimes to any given base a > 1. In 1904, Cipolla showed how to produce an infinite number of pseudoprimes to base a > 1: let A = (ap - 1)/(a - 1) and let B = (ap + 1)/(a + 1), where p is a prime number that does not divide a(a2 - 1). Then n = AB is composite, and is a pseudoprime to base a.[3][4] For example, if a = 2 and p = 5, then A = 31, B = 11, and n = 341 is a pseudoprime to base 2.
In fact, there are infinitely many strong pseudoprimes to any base greater than 1 (see Theorem 1 of
[5]) and infinitely many Carmichael numbers,[6] but they are comparatively rare. There are three pseudoprimes to base 2 below 1000, 245 below one million, and 21853 less than 25·109. There are 4842 strong pseudoprimes base 2 and 2163 Carmichael numbers below this limit (see Table 1 of [5]).
Starting at 17·257, the product of consecutive Fermat numbers is a base-2 pseudoprime, and so are all Fermat composites and Mersenne composites.
The probability of a composite number n passing the Fermat test approaches zero for . Specifically, Kim and Pomerance showed the following: The probability that a random odd number n ≤ x is a Fermat pseudoprime to a random base is less than 2.77·10-8 for x= 10100, and is at most (log x)-197<10-10,000 for x≥10100,000.[7]
Factorizations
The factorizations of the 60 Poulet numbers up to 60787, including 13 Carmichael numbers (in bold), are in the following table.
A Poulet number all of whose divisors d divide 2d − 2 is called a super-Poulet number. There are infinitely many Poulet numbers which are not super-Poulet Numbers.[8]
Smallest Fermat pseudoprimes
The smallest pseudoprime for each base a ≤ 200 is given in the following table; the colors mark the number of prime factors. Unlike in the definition at the start of the article, pseudoprimes below a are excluded in the table. (For that to allow pseudoprimes below a, see OEIS: A090086)
If composite is even, then is a Fermat pseudoprime to the trivial base .
If composite is odd, then is a Fermat pseudoprime to the trivial bases .
For any composite , the number of distinct bases modulo , for which is a Fermat pseudoprime base , is
[9]: Thm. 1, p. 1392
where are the distinct prime factors of . This includes the trivial bases.
For example, for , this product is . For , the smallest such nontrivial base is .
Every odd composite is a Fermat pseudoprime to at least two nontrivial bases modulo unless is a power of 3.[9]: Cor. 1, p. 1393
For composite n < 200, the following is a table of all bases b < n which n is a Fermat pseudoprime. If a composite number n is not in the table (or n is in the sequence A209211), then n is a pseudoprime only to the trivial base 1 modulo n.
n
bases 0 < b < n to which n is a Fermat pseudoprime
For more information (n = 201 to 5000), see b:de:Pseudoprimzahlen: Tabelle Pseudoprimzahlen (15 - 4999) (Table of pseudoprimes 16–4999). Unlike the list above, that page excludes the bases 1 and n−1. When p is a prime, p2 is a Fermat pseudoprime to base bif and only ifp is a Wieferich prime to base b. For example, 10932 = 1194649 is a Fermat pseudoprime to base 2, and 112 = 121 is a Fermat pseudoprime to base 3.
The number of the values of b for n are (For n prime, the number of the values of b must be n − 1, since all b satisfy the Fermat little theorem)
The number of the values of b for a given n must divide (n), or A000010(n) = 1, 1, 2, 2, 4, 2, 6, 4, 6, 4, 10, 4, 12, 6, 8, 8, 16, 6, 18, 8, 12, 10, 22, 8, 20, 12, 18, 12, 28, 8, 30, 16, 20, 16, 24, 12, 36, 18, 24, 16, 40, 12, 42, 20, 24, 22, 46, 16, 42, 20, ... The quotient can be any natural number, and the quotient = 1 if and only ifn is a prime or a Carmichael number (561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841, ... A002997) The quotient = 2 if and only if n is in the sequence: 4, 6, 15, 91, 703, 1891, 2701, 11305, 12403, 13981, 18721, ... A191311.)
The least numbers which are pseudoprime to k values of b are (or 0 if no such number exists)
1, 3, 28, 5, 66, 7, 232, 45, 190, 11, 276, 13, 1106, 0, 286, 17, 1854, 19, 3820, 891, 2752, 23, 1128, 595, 2046, 0, 532, 29, 1770, 31, 9952, 425, 1288, 0, 2486, 37, 8474, 0, 742, 41, 3486, 43, 7612, 5589, 2356, 47, 13584, 325, 9850, 0, ... (sequence A064234 in the OEIS) (if and only ifk is even and not totient of squarefree number, then the kth term of this sequence is 0.)
Weak pseudoprimes
A composite number n which satisfies is called a weak pseudoprime to base b. For any given base b, all Fermat pseudoprimes are weak pseudoprimes, and all weak pseudoprimes coprime to b are Fermat pseudoprimes. However, this definition also permits some pseudoprimes which are not coprime to b.[10] For example, the smallest even weak pseudoprime to base 2 is 161038 (see OEIS: A006935).
The least weak pseudoprime to bases b = 1, 2, ... are:
Carmichael numbers are weak pseudoprimes to all bases, thus all terms in this list are less than or equal to the smallest Carmichael number, 561. Except for 561 = 3⋅11⋅17, only semiprimes can occur in the above sequence. Not all semiprimes less than 561 occur; a semiprime pq (p ≤ q) less than 561 occurs in the above sequences if and only ifp − 1 divides q − 1 (see OEIS: A108574). The least Fermat pseudoprime to base b (also not necessary exceeding b) (OEIS: A090086) is usually semiprime, but not always; the first counterexample is A090086(648) = 385 = 5 × 7 × 11.
If we require n > b, the least weak pseudoprimes (for b = 1, 2, ...) are:
The rarity of such pseudoprimes has important practical implications. For example, public-key cryptography algorithms such as RSA require the ability to quickly find large primes. The usual algorithm to generate prime numbers is to generate random odd numbers and test them for primality. However, deterministic primality tests are slow. If the user is willing to tolerate an arbitrarily small chance that the number found is not a prime number but a pseudoprime, it is possible to use the much faster and simpler Fermat primality test.
^Sierpinski, W. (1988-02-15), "Chapter V.7", in Ed. A. Schinzel (ed.), Elementary Theory of Numbers, North-Holland Mathematical Library (2 Sub ed.), Amsterdam: North Holland, p. 232, ISBN9780444866622
W. F. Galway and Jan Feitsma, Tables of pseudoprimes to base 2 and related data (comprehensive list of all pseudoprimes to base 2 below 264, including factorization, strong pseudoprimes, and Carmichael numbers)