Work out fermat little theorem instantly with clear inputs, formula shown and shareable results.
Fermat's little theorem says that if p is prime and a is not a multiple of p, then a^(p−1) ≡ 1 (mod p). The converse is not quite true: some composites, such as 561, pass for particular bases.
Fermat's little theorem
a^(p−1) ≡ 1 (mod p) for prime p and a not divisible by p
Equivalent form
aᵖ ≡ a (mod p) for every a
2¹⁶ mod 17 = 1, as the theorem requires since 17 is prime.
A composite that passes the Fermat test for every coprime base. 561 is the smallest, which is why probabilistic tests use stronger checks.