Fermat's little theorem
Let’s dive into Fermat’s Little Theorem (FLT) :
1. What it says
If is a prime number and is an integer not divisible by , then:
This means that when you raise to the power and divide by , the remainder is 1.
2. A slightly different but equivalent form
Sometimes it’s written as(a is any integer but p has to be prime):
This form works even if is divisible by .
(You can get it by multiplying the first form by .)
3. Step-by-step example
Example 1:
Let (prime), (not divisible by 7).
FLT says:
Let’s check:
remainder 1 ✅
Example 2:
, :
FLT:
, remainder 1 ✅
Example 3 (alternate form):
,
FLT (alt form):
Let’s check: is huge, but modular arithmetic shortcuts show
, so multiply both sides by ⇒ ✅
4. Why it’s useful
-
Primality testing: It’s the basis for some fast prime tests (like the Fermat primality test — although there are exceptions called Carmichael numbers).
-
Modular inverses: If , then is the inverse of modulo .
-
Cryptography: Powers mod appear all over RSA, Diffie–Hellman, and elliptic curve cryptography.
Proof:
Here’s the elegant proof of Fermat’s Little Theorem using the “multiply all the numbers” trick.
Proof (for prime, not divisible by )
-
Start with the set of numbers:
These are all the positive integers less than .
-
Multiply each by :
Since is prime and is not divisible by , multiplying by just rearranges these numbers modulo .
That is, are all distinct mod and are just a permutation of .
-
Take the product of all the terms (mod ):
On one hand:
On the other hand, since it’s just a rearrangement:
-
Cancel the factorial part:
The product is not divisible by , so it has a multiplicative inverse modulo .
Cancelling it from both sides gives:
✅ This is exactly Fermat’s Little Theorem.
Detailed explanation of step 2 above:
Step 2: Why are all distinct mod
We’re working modulo , where is prime and is not divisible by .
We want to show that if
then .
Reasoning:
-
means:
-
Since is prime, if divides the product , then must divide either or .
-
But is not divisible by (that’s an assumption of the theorem),
so the only option is that divides . -
And because , the difference is between and , so the only way divides is if , i.e.:
Conclusion:
Multiplying by modulo doesn’t make any two numbers “collapse” into the same remainder — it just reorders them.
That’s why are a permutation of in mod land.
Comments
Post a Comment