Fermat's Little Theorem Calculator

Verify Fermat's Little Theorem, find multiplicative inverses, and test primality

Calculate Fermat's Little Theorem

Any positive integer

Must be a prime number

Choose calculation type

Fermat's Little Theorem

General Form:

a^p ≡ a (mod p)

For any integer a and prime p

Coprime Form:

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

When gcd(a,p) = 1

Examples

Example 1:

a = 3, p = 7

3^6 ≡ 1 (mod 7)

Since gcd(3,7) = 1

Example 2:

a = 14, p = 7

14^7 ≡ 14 (mod 7)

Since gcd(14,7) = 7 ≠ 1

Tips & Applications

p must be prime for the theorem to apply

Used in RSA cryptography

Helps find multiplicative inverses

Useful for primality testing

Foundation of modular arithmetic

Understanding Fermat's Little Theorem

What is Fermat's Little Theorem?

Fermat's Little Theorem is a fundamental result in number theory. It provides a relationship between modular exponentiation and prime numbers, forming the basis for many cryptographic algorithms.

The Two Forms:

General Form

For any integer a and prime p:

a^p ≡ a (mod p)

Coprime Form

When gcd(a,p) = 1:

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

Mathematical Applications

Cryptography

Foundation of RSA encryption and digital signatures

Multiplicative Inverses

Find a^(-1) ≡ a^(p-2) (mod p) when p is prime

Primality Testing

Fermat primality test (probabilistic)

Modular Arithmetic

Simplify large exponentiation problems

Historical Context

1640

Pierre de Fermat states the theorem in a letter to Frénicle de Bessy

1683

Leibniz discovers a proof but keeps it unpublished

1736

Euler publishes the first proof of Fermat's Little Theorem

Important Notes

• The theorem is called "little" to distinguish it from Fermat's Last Theorem

• The Fermat primality test can have false positives (Carmichael numbers)

• The theorem only works when p is prime

• When a and p are not coprime, use the general form a^p ≡ a (mod p)

• This theorem is fundamental to modern cryptography and computer science