Math

Fermat's Little Theorem Calculator

Compute aᵖ⁻¹ mod p, which is 1 when p is prime and a is not a multiple of p.

Parameters Live Compute
Calculated Output
aᵖ⁻¹ mod p 1
Equals 1? yes
Formula: aᵖ⁻¹ ≡ 1 (mod p) for prime p
Step-by-Step Breakdown
1. Values used:
2. Base a = 3
3. Prime p = 7
4.
5. aᵖ⁻¹ mod p = 1
6. Equals 1? = yes
Did this calculator solve your problem today?
Report issue to loopingon.com
Sponsored

Fermat's Little Theorem is a cornerstone of number theory and underpins primality testing and RSA.

The math behind it

If p is prime and a is not divisible by p, then aᵖ⁻¹ ≡ 1 (mod p). A result other than 1 proves p is composite.

Worked Example

3⁶ mod 7 = 729 mod 7 = 1, confirming 7 is prime.

Frequently Asked Questions

Does result 1 prove p is prime?

Not always — some composites (Carmichael numbers) also pass; it's a strong hint, not a proof.

Advertisement