LearnViz Math
Expert ⛓ Discrete Math & Number Theory Topic 81 of 103

Fermat’s Little Theorem

For prime p, aᵖ ≡ a mod p.

Key idea

For prime p, aᵖ ≡ a mod p.

In depth

If p is prime and p ∤ a, then aᵖ⁻¹ ≡ 1 (mod p). Equivalent: aᵖ ≡ a (mod p) for all a. It follows since multiplication by a permutes the non-zero residues.

Worked example

3⁶ = 729 ≡ 1 (mod 7). And 2¹⁰⁰ mod 7: 100 ≡ 4 (mod 6), so 2⁴ = 16 ≡ 2.

Formula

aᵖ⁻¹ ≡ 1 (mod p)

Real-world uses

Common mistake

Using it when p is not prime.

How to learn this

  1. Read the key idea and say it in your own words.
  2. Work through the worked example, then try a similar problem.
  3. Use the interactive lesson’s visual and mini-quiz to check the pattern.

Frequently asked questions

What is Fermat’s Little Theorem?

For prime p, aᵖ ≡ a mod p. It is a topic at the expert level in Discrete Math & Number Theory.

What is the formula for Fermat’s Little Theorem?

The key formula is aᵖ⁻¹ ≡ 1 (mod p).

Where is Fermat’s Little Theorem used in real life?

Real-world examples: Testing whether a huge number is likely prime and simplifying modular powers in cryptography.

What should I learn before Fermat’s Little Theorem?

Make sure you are comfortable with Chinese Remainder Theorem, the previous topic in Discrete Math & Number Theory.

What is a common mistake with Fermat’s Little Theorem?

Using it when p is not prime.

How can I practise Fermat’s Little Theorem?

Open the interactive lesson, play with the visual, then answer the three-question mini-quiz. Getting two right marks the topic complete.

What comes after Fermat’s Little Theorem?

Move on to Euler’s Totient Function next.

Related expert topics in Discrete Math & Number Theory