2.5.11Number Theory (Intermediate)

Fermat's little theorem (statement)

2,133 words10 min readdifficulty · medium3 backlinks

Statement of the Theorem

What Each Part Means

  • pp is prime: This theorem only works for primes. Try p=4p = 4 (composite) with a=2a = 2: we get 23=80(mod4)2^{3} = 8 \equiv 0 \pmod{4}, not1.
  • gcd(a,p)=1\gcd(a, p) = 1: The number aa must be coprime to pp. If aa is a multiple of pp, then ap10(modp)a^{p-1} \equiv 0 \pmod{p}, not 1.
  • ap11(modp)a^{p-1} \equiv 1 \pmod{p}: When you compute ap1a^{p-1} and divide by pp, the remainder is exactly 1.

Building the Intuition: Why Would This Be True?

Worked Examples

Common Mistakes & How to Avoid Them

Key Formulas & When to Use Them

Applications Preview

  1. Modular Inverses: To find a1modpa^{-1} \bmod p, compute ap2modpa^{p-2} \bmod p (since aap2=ap11a \cdot a^{p-2} = a^{p-1} \equiv 1).

  2. Fast Exponentiation: Computing anmodpa^n \bmod p becomes efficient: reduce nmod(p1)n \bmod (p-1) first.

  3. Primality Testing: If ap1≢1(modp)a^{p-1} \not\equiv 1 \pmod{p} for coprime aa, then pp is definitely composite (though the converse isn't always true—leads to Fermat pseudoprimes).

  4. RSA Encryption: The security of RSA relies on a generalization of FLT (Euler's theorem).

Recall Explain to a 12-Year-Old

Imagine you have a special clock that only goes up to a prime number of hours—say 5 hours. Now, pick any number that doesn't land exactly on one of the hour marks when you divide evenly (like 3).

Fermat discovered something magical: if you keep multiplying your number by itself exactly (51)=4(5-1) = 4 times, and then see where you land on the clock, you'll always end up back at 1o'clock!

So 3×3×3×3=813 \times 3 \times 3 \times 3 = 81. If we go around our5-hour clock, 81 hours later is the same as 1 o'clock (since 81=16×5+181 = 16 \times 5 + 1).

This only works when your clock has a prime number of hours. If it's 4 hours (not prime), the magic breaks. That's why primes are special—they have this hidden pattern that regular numbers don't.

Connections

  • Modular Arithmetic Basics - prerequisite for understanding ap11(modp)a^{p-1} \equiv 1 \pmod{p}
  • Properties of Prime Numbers - why this theorem is exclusive to primes
  • Euler's Totient Function - generalizes FLT to composite moduli via Euler's theorem
  • Wilson's Theorem - another special property of primes involving (p1)!(p-1)!
  • Carmichael Numbers - composites that "fake" Fermat's theorem for all bases
  • Multiplicative Group Modulo Prime - the group theory foundation ((Z/pZ)(\mathbb{Z}/p\mathbb{Z})^* has order p1p-1)
  • Modular Exponentiation Algorithms - using FLT to speed up computations
  • RSA Cryptosystem - relies on generalizing FLT for security

#flashcards/maths

What does Fermat's Little Theorem state for a prime p and integer a where gcd(a,p)=1? :: ap11(modp)a^{p-1} \equiv 1 \pmod{p}

What are the two conditions required for the classical form of Fermat's Little Theorem?
(1) pp must be prime, (2) gcd(a,p)=1\gcd(a, p) = 1 (a is coprime to p)
What is the alternative form of Fermat's Little Theorem that works for all integers a?
apa(modp)a^p \equiv a \pmod{p} when pp is prime
Why does Fermat's Little Theorem fail for composite moduli?
Because theorem relies on the multiplicative group modulo p having exactly p-1 elements, which only happens when p is prime; composite moduli don't have this structure
How can you use FLT to find the modular inverse of a modulo prime p?
a1ap2(modp)a^{-1} \equiv a^{p-2} \pmod{p}, since aap2=ap11(modp)a \cdot a^{p-2} = a^{p-1} \equiv 1 \pmod{p}
If you need to compute 7222mod117^{222} \bmod 11 using FLT, what is the first step?
Express 222 as 222=1022+2222 = 10 \cdot 22 + 2 where 10 = p-1, then use 7101(mod11)7^{10} \equiv 1 \pmod{11} to simplify to 72mod117^2 \bmod 11
What mistake do students make when applying FLT to a=6, p=3?
They forget to check gcd(6,3)=31\gcd(6,3) = 3 \neq 1, so the condition gcd(a,p)=1\gcd(a,p)=1 fails and FLT doesn't apply; 620(mod3)6^2 \equiv 0 \pmod{3}, not 1

Concept Map

required for

required for

main form

alternative form

holds when coprime

holds for any a

reorders set

multiply all, cancel factorial

rigorous proof

simplifies

foundation for

p is prime

Fermat's Little Theorem

gcd a,p = 1

a^p-1 = 1 mod p

a^p = a mod p

Any integer a

Multiplication by a is bijection

1..p-1 mod p

Lagrange's theorem

Modular exponentiation

RSA and primality testing

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Fermat's Little Theorem ek bahut hi powerful result hai number theory mein. Iska matlab simple hai:agar apke pas ek prime number pp hai aur koi bhi integer aa hai jo pp se divide nahi hota (matlab gcd(a,p)=1\gcd(a,p) = 1), to jab aap aa ko (p1)(p-1) baar multiply karke power mein late ho aur phir pp se divide karte ho, to remainder hamesha 1 ata hai. Formula yeh hai: ap11(modp)a^{p-1} \equiv 1 \pmod{p}.

Yeh theorem isliye important hai kyunki yeh humein bahut bade exponents ko simplify karne mein mad karta hai. For example, agar aapko 7222mod117^{222} \bmod 11 nikalna hai, to seedha calculate karna mushkil hai. Lekin FLT kehta hai ki 7101(mod11)7^{10} \equiv 1 \pmod{11} (kyunki 11 prime hai aur 111=1011-1=10). Ab222 ko 10×22+210 \times 22 + 2 likh sakte ho, matlab 7222=(710)2272122495(mod11)7^{222} = (7^{10})^{22} \cdot 7^2 \equiv 1^{22} \cdot 49 \equiv 5 \pmod{11}. Kitna asaan ho gaya!

Yeh theorem cryptography (RSA jaise systems), primality testing (kya yeh number prime hai check karne ke liye), aur modular arithmetic problems mein extensively use hota hai.Ek important baat yad rakhni hai: yeh sirf prime modulus ke liye kaam karta hai.Agar aap composite number jaise 4 ya 6 pe apply karoge, to galat answer ayega. Aur dusri condition yeh hai ki aa aur pp coprime hone chahiye—yani unka GCD exactly 1 hona chahiye. Agar aa already pp ka multiple hai, to ap1a^{p-1} zero hoga, ek nahi.

Go deeper — visual, from zero

Test yourself — Number Theory (Intermediate)

Connections