Fermat's Little Theorem Calculator
Verify standard and alternative forms of Fermat's Little Theorem with fast modular exponentiation.
About Fermat's Little Theorem
Fermat's Little Theorem examples
Each example reduces a power without constructing the full value.
| Inputs and form | Remainder | Interpretation |
|---|---|---|
| a = 2, p = 7, standard | 2^6 mod 7 = 1 | The standard congruence is verified. |
| a = 3, p = 11, standard | 3^10 mod 11 = 1 | A classic prime-modulus example. |
| a = 5, p = 13, alternative | 5^13 mod 13 = 5 | The alternative form returns the base remainder. |
| a = 17, p = 17, alternative | 17^17 mod 17 = 0 | The alternative form remains valid when p divides a. |
How to use the theorem calculator
- Enter an integer greater than 1 as the base a.
- Enter a prime integer as the modulus p.
- Choose the standard form for coprime inputs or the alternative form for any integer base.
- Select Calculate Theorem to evaluate the power with modular exponentiation.
- Review the remainder and verification statement.
Fermat's Little Theorem FAQ
What does modulo p mean?
Modulo p means that numbers are compared by their remainders after division by p. Two numbers are congruent modulo p when those remainders match.
Why must p be prime?
Primality is a required hypothesis of Fermat's Little Theorem. Composite moduli do not consistently satisfy the congruence, although some can pass selected tests.
What is the difference between the two theorem forms?
The standard form returns 1 and requires a to be coprime to p. The alternative form returns the same remainder as a and works for every integer a when p is prime.
Does passing a Fermat test prove a number is prime?
No, some composite numbers pass Fermat tests for certain bases. A failed test proves compositeness, but a passed test requires stronger primality checks for certainty.
How does fast modular exponentiation work?
It decomposes the exponent into binary powers and repeatedly squares the base. Reducing after every multiplication keeps values small while preserving the exact remainder.