🔢 Fermat's Little Theorem Calculator

Verify Fermat's Little Theorem for modular arithmetic

How to Use This Calculator

1

Enter Base and Prime

Enter a (base) and p (prime modulus). They must be coprime.

2

Click Verify

Press button to check if a^(p-1) ≡ 1 (mod p).

Fermat's Little Theorem

If p is prime and gcd(a, p) = 1, then:

a^(p-1) ≡ 1 (mod p)

Example: a = 3, p = 7

Check: 3^(7-1) = 3^6 ≡ ? (mod 7)

3^1 = 3 mod 7 = 3

3^2 = 9 mod 7 = 2

3^6 = (3^2)^3 = 2^3 = 8 ≡ 1 (mod 7) ✓

About Fermat's Little Theorem Calculator

Fermat's Little Theorem states that if p is prime and a is coprime to p, then a raised to the (p-1) power is congruent to 1 modulo p.

When to Use This Calculator

  • Number Theory: Verify modular exponentiation
  • Cryptography: Understand RSA and modular arithmetic
  • Education: Learn Fermat's theorem
  • Research: Check number theory properties

Why Use Our Calculator?

  • Instant Verification: Check theorem instantly
  • Modular Exponentiation: Efficient calculation
  • Educational: Learn theorem concepts
  • Completely Free: No registration required

Requirements

  • p must be a prime number
  • a and p must be coprime (GCD = 1)
  • Theorem states: a^(p-1) ≡ 1 (mod p)

Frequently Asked Questions

What is Fermat's Little Theorem?

If p is prime and gcd(a,p)=1, then a^(p-1) ≡ 1 (mod p). A fundamental result in number theory.

Why must a and p be coprime?

If a and p share a factor, the theorem doesn't hold. For example, 2^(4-1) mod 4 = 8 mod 4 = 0 ≠ 1 (2 and 4 not coprime).

What is this used for?

Prime testing (Miller-Rabin), modular inverses, and cryptographic algorithms like RSA rely on this theorem.