Fermat's Little Theorem Calculator

Your details

The base integer. Must not be divisible by p for the coprime form of the theorem to apply.
The modulus. Must be a prime number. The calculator will warn you if the value is not prime.
The coprime form requires gcd(a, p) = 1. The general form holds for any integer a (including multiples of p).
Theorem resultTheorem verified
1

The value of the modular exponentiation (should equal 1 in coprime form)

a^p mod p3
a mod p3
Modular inverse of a5
gcd(a, p)1
Theorem result (expect 1)1
a mod p3
gcd(a, p)1

Fermat's Little Theorem: 3^6 ≡ 1 (mod 7)

  • 7 is prime, so Fermat's Little Theorem applies.
  • gcd(3, 7) = 1, confirming a and p are coprime. The result a^(p-1) mod p should equal 1.
  • The modular multiplicative inverse of 3 mod 7 is 5, because 3 x 5 ≡ 1 (mod 7). Computed via a^(p-2) mod p.

Next stepUse the modular inverse in RSA-style key exchange or to solve linear congruences of the form ax ≡ b (mod p).

= Powered by OnlyCalculators