ArticleslgStudy

computer science

Fermat pseudoprime

Fermat pseudoprime is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Fermat pseudoprime rather than just read about it. In short: In number theory, the Fermat pseudoprimes make up the most important class of pseudoprimes that come from Fermat's little theorem. Definition Fermat's little theorem states that if p is prime and a is coprime to p, then ap−1−1 is divisible by p.

Key takeaways

  • Fermat pseudoprime belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Fermat pseudoprime to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Fermat pseudoprime from memory before moving on to harder problems.

Reference excerpt

In number theory, the Fermat pseudoprimes make up the most important class of pseudoprimes that come from Fermat's little theorem.

Definition 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. 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. 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(mod341) 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.

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. For example, if a=2 and p=5, then A=31, B=11, and n=AB=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 ) and infinitely many Carmichael numbers, 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 ). 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 n→∞. Specifically, Kim and Pomerance showed the following: The probability that a random odd number n≤x is a Fermat pseudoprime to a random base 1<b<n−1 is less than 2.77·10−8 for x= 10100, and is at most (log x)−197<10−10,000 for x≥10100,000. For a fixed base b, the proportion of pseudoprimes up to x is at most e-log x log log log x/(2 log log x) for large x.

Factorizations The factorizations of the 60 Poulet numbers up to 60787, including 13 Carmichael numbers (in bold), are in the following table. (sequence A001567 in the OEIS)

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.

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 (sequence A090086 in the OEIS)) (sequence A007535 in the OEIS)

List of Fermat pseudoprimes in fixed base n

For more information (base 31 to 100), see (sequence A020159 in the OEIS) to (sequence A020228 in the OEIS), and for all bases up to 150, see table of Fermat pseudoprimes (text in German), this page does not define n is a pseudoprime to a base congruent to 1 or −1 (mod n)

Bases b for which n is a Fermat pseudoprime If composite n is even, then n is a Fermat pseudoprime to the trivial base b≡1(modn). If composite n is odd, then n is a Fermat pseudoprime to the trivial bases b≡±1(modn). For any composite n, the number of distinct bases b modulo n, for which n is a Fermat pseudoprime base b, is

∏i=1kgcd⁡(pi−1,n−1) where p1,…,pk are the distinct prime factors of n. This includes the trivial bases. For example, for n=341=11⋅31, this product is gcd⁡(10,340)⋅gcd⁡(30,340)=100. For n=341, the smallest such nontrivial base is b=2. Every odd composite n is a Fermat pseudoprime to at least two nontrivial bases modulo n unless n is a power of 3. 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.

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 b if and only if p 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)

1, 1, 2, 1, 4, 1, 6, 1, 2, 1, 10, 1, 12, 1, 4, 1, 16, 1, 18, 1, 4, 1, 22, 1, 4, 1, 2, 3, 28, 1, 30, 1, 4, 1, 4, 1, 36, 1, 4, 1, 40, 1, 42, 1, 8, 1, 46, 1, 6, 1, ... (sequence A063994 in the OEIS) The least base b > 1 which n is a pseudoprime to base b (or prime number) are

2, 3, 2, 5, 2, 7, 2, 9, 8, 11, 2, 13, 2, 15, 4, 17, 2, 19, 2, 21, 8, 23, 2, 25, 7, 27, 26, 9, 2, 31, 2, 33, 10, 35, 6, 37, 2, 39, 14, 41, 2, 43, 2, 45, 8, 47, 2, 49, 18, 51, ... (sequence A105222 in the OEIS) 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 if n 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)

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Fermat pseudoprime

Start with the simplest possible case. Write down what Fermat pseudoprime claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Fermat pseudoprime before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Fermat pseudoprime ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Fermat pseudoprime

In research
Fermat pseudoprime appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Fermat pseudoprime in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Fermat pseudoprime is common in secondary-school and first-year university syllabi. It links to neighbouring topics Asymmetric-key algorithms, Pierre de Fermat, Pseudoprimes, so understanding it makes those chapters shorter.
In everyday life
Look for Fermat pseudoprime outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Fermat pseudoprime” →

How to study Fermat pseudoprime in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Fermat pseudoprime means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Fermat pseudoprime out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Fermat pseudoprime in simple terms?

In number theory, the Fermat pseudoprimes make up the most important class of pseudoprimes that come from Fermat's little theorem. Definition Fermat's little theorem states that if p is prime and a is coprime to p, then ap−1−1 is divisible by p.

Why does Fermat pseudoprime matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Fermat pseudoprime?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Fermat pseudoprime.

Tags

  • Asymmetric-key algorithms
  • Pierre de Fermat
  • Pseudoprimes

Keep exploring