Fermat's Theorem
1. Statement (beginner words!)
If is prime and is NOT a multiple of , then:
Corolary (works for ALL ):
In words: powers cycle back to 1 every steps mod prime!
2. Worked Examples (exam numericals!)
p = 5, a = 2: 2⁴ = 16, 16 mod 5 = 1 ✓
p = 7, a = 3: 3⁶ = 729, 729 mod 7 = 1 ✓ (729 = 7×104 + 1!)
shortcut: 2¹⁰⁰ mod 7? 100 = 6×16 + 4 → 2¹⁰⁰ = (2⁶)¹⁶ × 2⁴ ≡ 1¹⁶ × 16 ≡ 2 mod 7!
3. Why Crypto Cares
- Primality hint: if mod for some , then is COMPOSITE (Fermat test base!).
- Inverse shortcut:
(used in RSA key gen!).
- Powers reduce exponents mod (fast mental math!).
4. Traps
- Needs PRIME ! ( mod , not 1 — 4 composite, theorem fails!).
- Needs coprime to ( multiple of → 0, not 1!).
- Converse FALSE: some composites pass for all coprime (Carmichael numbers, e.g. 561 — need Miller-Rabin!).
5. Exam Points
- State + verify ( mod ) — 5 marks, very frequent.
- Exponent-reduction numerical ( mod ) — 5 marks, favourite.
- Carmichael caveat — 3 marks, frequent viva.