Fermat Little Theorem
Fermat Little Theorem
Fermat Little Theorem
U
9
(1. a
3 it -1 a
5 a (i Ci
7 (I 8
1) 0 0 0 0 0 0 0
a, 2
a
(3 c11 ,5 ((()
11111111
000000 24124124
(1 a,2 3 (i
111111 32645132
0w0 0 0 243124 42142142
1 1 1 342134 54623154
2 1 414141 61616161
A modulo 3 a inodulo .5 a modulo 7
Many interesting patterns are visible in these tables. The one that we will be
From Chapter 9 of A Friend!)’ Jntrothfttion to Number Theory. Fourth Edition. Joseph H. Silverman.
Copyright © 2013 by Pearson Education, Inc. All rights reserved.
68 Congruences, Powers, and Ferrnat’s Little Theorem
Every entry in these columns. aside from the top one, is equal to 1. Does this
pattern continue to hold for larger primes? You can check the table YOU made for
p = 11, and you will find that
310
110 1 (mod 11). 210
1 (mod 11), 1 (mod 11)...
910
1 (mod 11). and 1010 1 (mod 11).
and a2 differ by a multiple of p. then their powers will be the same modulo p. So
the real condition on a is that it not be a multiple of p. This result was first stated
by PielTe de Fermat in a letter to Frénicle de Bessy dated 1640. but Fermat gave
no indication of his proof. The first known proof appears to be due to Gottfried
Leibnizi
Theorem 1 (Fermat’s Little Theorem). Let p be a prune nianbe,; and let a be ant
number with a 0 (mod p). Then
1 (moclp).
Before giving the proof of Fermat’s Little Theorem we want to indicate its
power and show how it can he used to simplify computations. As a particular
xamp] e. consider the congruence
This says that the number 622 1 is a multiple of 2:3. If we wanted to check this
—
622,
fact without using Fermat’s Little Theorem, we would have to inuhiply out
subtract I, and divide by 23. Here’s what we get:
Gotifried Leibniz (1646—1716) is best known as one of the discoverers of the calculus. He and
Isaac Newton worked out the main theorems of the calculus independently and at about the same
time. The German and Engtish mathematical communities spent the next two centuries arguing over
who deserved priority. The current consensus is that both Leihniz and Newton should be given joint
credit as the (independent) discoverers of the calculus.
Congruences. Powers, and Fermat’s Little Theorem 69
Similarly, in order to verify directly that 73100 1 (mod 101), we would have to
compute 73100 — 1. Unfortunately, 73100 1 has 187 digits! And notice that this
—
example only uses p = 101, which is a comparatively small prime. Fermat’s Little
Theorem thus describes a very surprising fact about extremely large numbers.
We can use Fermat’s Little Theorem to simplify computations. For example.
in order to compute (mod 7), we can use the fact that 26 1 (mod 7). So we
write 35 6 5 + 5 and use the law of exponents to compute
= 265±5 = (26)5 . 2 1° 2.
32 4 (mod 7)
Similarly, suppose that we want to solve the congruence 1103 4 (mod 11).
Certainly, .c 0 (mod 11), so Fermat’s Little Theorem tells us that
1 (mod 11).
(mod11) 0123 45 67 89 10
(rnodll)
3 0 1 8 5 94 72 6H 10
1, 2, 3, 4, 5, 6,
multiply each of them by 3. and reduce inodulo 7. The results are listed in the
following table:
•‘ X (mod 7) 1 2 3 4 5 6
3x (mod 7) 3 6 2 5 1 4
Notice that each of the numbers 1, 2,3,4.5,6 reappears exactly once in the second
row. So if we multiply together all the numbers in the second row, we get the same
70 Congruences. Powers, and Fermats Little Theorem
result as multiplying together all the numbers in the first row. Of course, we must
work modulo 7. Thus,
Factoring out the six factors of 3 on the left-hand side of our congruence gives
36
. 6! 6! (mccl 7).
Notice that 6! is relatively prime to 7, so we can cancel the 6! from, both sides. This
gives 36 ], (mod 7), which is exactly Fermat’s Little Theorem.
We are now ready to prove Fermat’s Little Theorem in general. The key ob
36 (mod 7) was that multiplication by 3 rearranged the
servation in our proof for
numbers 1.2. 3. -1. 5. 6 (mod 7). So first we are going to verify the following claim:
Lemma 2. Let J) be ci prime number cuid let (I be a number cit/i ci 0 (mod p).
Then the numbers
PIV0J. The list (I. 2u. 3u. (p 1 )u contains p 1 numbers, and clearly none of
—
—
them are divisible by p. Suppose that we take two numbers ju and kct in this list,
anti suppose that they happen to be congruent.
Then p I (.1 k)a. so J) (j /). since we are assuming that p does not divide ci.
—
—
Notice that we are using the Prime Divisibility Property, which says that if a prime
divides a product then it divides one of the factors. On the other hand. we know
absolute
that 1 j, k p 1, so Ij kI < p 1. There is only one number with
—
—
—
value less than v —1 that is divisible by p and that number is zero. Hence, j = k.
This shows that different multiples in the list a. 2u, 3a (p flu are distinct —
modulo p.
Congruences, Powers. and Fermat’s Little Theorem 71
nonzero values modulo p. But there are only p 1 distinct nonzero values mod
—
ulop. that is. the numbers 1.2.3 (13—1). Hence, the list a. 2ci. 30 (p— fla
and the list 1.2.3 (p—i) must contain the same numbers rnodulop. although
the numbers may appear in a different order. This finishes the proof of the lemma.
Using the lemma, it is easy to finish the proof of Fermat’s Little Theorem. The
lemma says that the lists of numbers
are the same, so the product of the numbers in the first list is equal to the product
of the numbers in the second list:
Fermat’s Little Theorem can he used to show that a number is not a prime
without actually factoring it. For example, it turns out that
This means that 12:3-1567 cannot be a prime, since if it ere, Fermats Little The—
oiem would tell us that 2 23 156(i niList be congruent tO 1 modulo 12:14567. it turns
out that 1231567 127 9721. so in this case we can actually find a lactor. But
consider the number
in = i0’ + 37.
‘\ hen we compute 2’’ (mod iim), we get
2T1 3626:3uu:3275-I5S61062487760i996335839i0
3687:325:3019151380128320821091 121859463
- 579459059730070231841:397 (mod in).
72 Congruences. Powers. and Fermat’s Little Theorem
Again we deduce from Fermats Little Theorem that 10100 + 37 is not prime, but it
is not at all clear how to find a factor. A quick check on a desktop computer reveals
no prime factors less than 200.000. It is somewhat surprising that we can easily
write down numbers that we know are composite, yet for which we are unable to
find any factors.
Exercises
1. Use Fermat’s Little Theorem to perform the following tasks.
979 (mod 73).
(a) Find a number 0 < a < 73 with (1
(b) Solve am 6 (mod 29).
9 3 (mud 13).
(c) Solve a
2. The quantity (p 1)! (mod p) appeared in our proof of Fermat’s Little Theorem, al
—
value it does for small values of p. and then generalize your observation to prove the
formula for all values of p.]
3. Exercise 2 asked you to determine the value of (p 1)! (mod p) when p is a prime
—
number.
(a) Compute the value of (iii — 1)! (mod iii) for some small values of rn that are not
prime. Do you find the same pattern as you found for primes?
(b) If you know the value of (n 1)! (mod ii). how can you use the value to definitely
distinguish whether ii is prime or composite?
4. If p is a prime number and if a 0 (mod p), then Fermat’s Little Theorem tells us that
ai’ 1 (mod p).
(a) The congruence 7h734250 1660565 (mod 1734251) is true. Can you conclude that
17342.51 is a composite number?
(b) The congruence l296b026 15179 (mod 64027) is true. Can you conclude that
61027 is a composite number?
(C) The congruence 2526:12 1 (mod 52633) is true. Can you conclude that 52633 is a
prime number?