Verify a^(p-1) mod p for a prime p and integer a with a live modular arithmetic check.
Last updated: June 2026 | By Patchworkr Team
If p is prime and a is not divisible by p, then a^(p-1) is congruent to 1 modulo p. This is one of the basic results behind modular arithmetic.
If p is not prime, or if a is a multiple of p, the theorem does not give the value 1. The calculator explains that case directly.
Example: 3^(7 - 1) mod 7 = 1, so the theorem holds.
Check a = 3 and p = 7.
1. Confirm that 7 is prime.
2. Compute 3^(7 - 1) mod 7 = 3^6 mod 7.
3. Reduce the power using modular exponentiation.
Final answer: 1
That is exactly what Fermat's Little Theorem guarantees when p is prime and a is not divisible by p.
No. The modulus must be a prime number greater than 1.
Yes. Negative integers are reduced modulo p before exponentiation.
It avoids huge intermediate values while still computing the correct residue.
Related Tools