Fermat's Little Theorem — Definition, Formula & Examples
Fermat's Little Theorem states that if is a prime number and is any integer not divisible by , then leaves a remainder of 1 when divided by .
Let be a prime and with . Then . An equivalent formulation, valid for all integers (including multiples of ), is .
Key Formula
Where:
- = Any integer not divisible by $p$
- = A prime number
How It Works
The theorem gives you a shortcut for computing large powers modulo a prime. Instead of calculating directly, you reduce the exponent modulo , since . Specifically, write ; then . This dramatically shrinks the computation. The theorem also underpins primality testing algorithms and the RSA cryptosystem.
Worked Example
Problem: Compute .
Step 1: Since 7 is prime and 3 is not divisible by 7, Fermat's Little Theorem gives us:
Step 2: Reduce the exponent 100 modulo 6 (since ):
Step 3: Replace the exponent with the remainder and compute:
Answer:
Why It Matters
Fermat's Little Theorem is foundational to RSA encryption, where messages are encoded and decoded using modular exponentiation with large primes. It also forms the basis of the Fermat primality test, a fast probabilistic method for checking whether a number is prime. In an abstract algebra course, it appears as a special case of Lagrange's theorem applied to the multiplicative group .
Common Mistakes
Mistake: Applying the theorem when the modulus is not prime (e.g., using ).
Correction: Fermat's Little Theorem requires to be prime. For composite moduli, use Euler's theorem with the Euler totient function instead.
