Two named theorems that shortcut huge modular powers, plus the idea of an element's order — how long its power cycle actually is.
Fermat’s Little Theorem
If p is prime and gcd(a,p)=1:
ap−1≡1(modp)
An equivalent form that works even when p∣a: ap≡a(modp).
Euler’s theorem
Euler’s theorem generalizes Fermat’s to any modulus, not just primes, using Euler’s totient function φ(m) (the count of integers from 1 to m that are coprime tom):
aφ(m)≡1(modm)whenever gcd(a,m)=1
For a prime p, φ(p)=p−1, recovering Fermat’s theorem as a special case.
Multiplicative order
The order of a modulo m is the smallest positive integer k such that ak≡1(modm). The order always exists when gcd(a,m)=1, and — this is the key structural fact — the order always divides φ(m), and more generally divides any exponent n for which an≡1(modm). This is often the fastest way to find an exponent cycle length: it must be a divisor of φ(m), so you only need to test those divisors rather than every possible length.
Worked example
Problem: Find the last two digits of 72024 (i.e. 72024mod100).
Solution:gcd(7,100)=1, and φ(100)=φ(4)φ(25)=2×20=40. By Euler’s theorem, 740≡1(mod100). Reduce the exponent:
2024=40×50+24⟹72024≡724(mod100)
Computing 724mod100 by repeated squaring: 72=49,74=492=2401≡1, so 74≡1(mod100) already (the actual order divides 40 and turns out to be 4). Then 724=(74)6≡16=1(mod100).
So the last two digits of 72024 are 01.
Practice problems
1.Use Fermat’s Little Theorem to find 212mod13.
2.Find φ(12).
3.Find the remainder when 5203 is divided by 13, using Fermat’s theorem.