Fermat’s Little Theorem definition
Fermat’s little theorem says that if p is prime and p does not divide a, then a^(p − 1) ≡ 1 (mod p).
Fermat’s Little Theorem in a picture
How it works
An equivalent form is aᵖ ≡ a (mod p) for every integer a. The theorem helps reduce large powers modulo a prime. A composite modulus can sometimes satisfy the same congruence for a chosen base, so passing a Fermat test does not prove primality in general.
Worked examples
Find 2⁶ modulo 7.
1, by the theorem.
Find 2¹⁰ modulo 7.
2⁶ ≡ 1, so 2¹⁰ ≡ 2⁴ ≡ 2.
Does a ≡ 0 (mod p) satisfy a^(p − 1) ≡ 1?
No. The condition excludes bases divisible by p.
Common mistake
Verify that the modulus is prime and that the base is coprime to it before using the first form.
Quick check
What must p be?
Show answer
Prime.
What power has remainder 1 when p does not divide a?
Show answer
The (p − 1)st power.
Does the theorem work as a complete proof of primality?
Show answer
No. Some composites pass a Fermat test for particular bases.
Sources
Flashcard
Fermat’s Little Theorem
Reveal the definition
Fermat’s little theorem says that if p is prime and p does not divide a, then a^(p − 1) ≡ 1 (mod p).
Effortless Math. “Fermat’s Little Theorem.” Math Dictionary.



