Pseudoprimes
If a and p are coprime numbers such that a p−1 − 1 is divisible by p, then p need not be prime. If it is not, then p is called a pseudoprime to base a. F. Sarrus in 1820 found 341 = 11 × 31 as one of the first pseudoprimes, to base 2.
A number p that is a pseudoprime to base a for every number a coprime to p is called a Carmichael number (e.g. 561). Alternately, any number satisfying the equality
is either a prime or Carmichael number.
Read more about this topic: Fermat's Little Theorem