Fermat's Little Theorem Calculator
Compute aᵖ⁻¹ mod p, which is 1 when p is prime and a is not a multiple of p.
Fermat's Little Theorem is a cornerstone of number theory and underpins primality testing and RSA.
The math behind it
If p is prime and a is not divisible by p, then aᵖ⁻¹ ≡ 1 (mod p). A result other than 1 proves p is composite.
Worked example
3⁶ mod 7 = 729 mod 7 = 1, confirming 7 is prime.
FAQ
Does result 1 prove p is prime?
Not always — some composites (Carmichael numbers) also pass; it's a strong hint, not a proof.