You are on page 1of 3

Chapter 9

Fermat’s Little Theorem

9.1 Notes
Fermat’s little theorem gives a nice method to determine remainders when certain
exponents are divided by primes. We give a couple definitions that will be useful here and
in the next chapter:

Definition 9.1.1. A set of integers is called a reduced residue system modulo m if every
integer in the set is relatively prime to m, and no two elements in the set are congruent
modulo m.

Example 9.1.2. Is {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} a reduced residue system modulo 10? What


about {1, 3, 7, 9}?

Solution. {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} is not a reduced residue system modulo 10, as it contains


even numbers which share a common factor (note that this is a complete residue system).
The set {1, 3, 7, 9} is a reduced residue system modulo 10.

Note that if p is a prime, then any reduced residue system has p − 1 elements. We
usually use the set {0, 1, 2, . . . , p − 1} for simplicity.

Theorem 9.1.3 (Fermat’s Little Theorem). Let p be a prime, and a be a positive integer
that is not divisible by p. Then

ap−1 ≡ 1 (mod p)

Proof. We can consider the reduced residue system {1, 2, 3, . . . , p − 1} modulo p. The
product of all elements in the set is (p − 1)!.
Suppose we multiply each element by a: {a, 2a, 3a, . . . , (p − 1)a}. We can show that
this set, taken modulo p, is also a reduced residue system by noting that no two elements
in the set are congruent modulo p. The product of the elements is ap−1 (p − 1)!.

38
MC35N Chapter 9. Fermat’s Little Theorem

Since the product of elements in {a, 2a, 3a, . . . , (p − 1)a} should also be the same as the
product of the elements in {1, 2, 3, . . . , p − 1}, taken modulo p, we have

ap−1 (p − 1)! ≡ (p − 1)! (mod p)


p−1
a (p − 1)! − (p − 1)! ≡ 0 (mod p)
p−1
(p − 1)!(a − 1) ≡ 0 (mod p)

Since (p − 1)! is not divisible by prime p, it follows that ap−1 − 1 is divisible by p, so


ap−1 ≡ 1 (mod p) as desired.

Equivalently, we have the following:


Corollary 9.1.4. Let p be a prime, and a be a positive integer. Then

ap ≡ a (mod p)

This is an equivalent statement of Fermat’s little theorem, without the restriction that
gcd(a, p) = 1.
711
Example 9.1.5. Find 35 (mod 7).
711
Solution. By Fermat’s little theorem, we have 36 ≡ 1 (mod 7), so 35 ≡ 3a (mod 7),
711 11
where a ≡ 5 (mod 6) and 0 ≤ a < 6. Since 5 ≡ −1 (mod 6), so a ≡ (−1)7 ≡ −1 ≡ 5
(mod 6). So we want 35 ≡ 243 ≡ 5 (mod 7).

Example 9.1.6. For how many primes p is 5p−2 ≡ 7 (mod p)?


Proof. Clearly p = 5 does not work, so assume p 6= 5. Then multiplying both sides by 5,
we get that 5p−1 ≡ 1 ≡ 35 (mod p). Then p | 34, so either p = 2 or p = 17. Thus there
are 2 solutions.

9.2 Examples
1. (Ata Pir) Find the remainder when 364 is divided by 67.

2. (Ata Pir) Find the largest two digit number x such that x7 ≡ 3 (mod 11).

3. (Harry Wang) If it exists, find a positive integer n for which 20n + 15n − 12n ≡ 0
(mod 29).

4. (Patrick Lin) (CHALLENGE) Find the remainder when

N = 19 + 29 + · · · + 349

is divided by 11.

39
MC35N Chapter 9. Fermat’s Little Theorem

9.3 Exercises
1. (SMT-2012-Advanced Topics-7) Determine the greatest common divisor of the ele-
ments of the set {n13 − n | n is an integer}.

2. (Ata Pir) Find the number of integer solutions of the equation x12 −11x6 y 5 +y 10 = 8.

3. (SMT-2019-Discrete-1) How many nonnegative integers less than 2019 are not solu-
tions to x8 + 4x6 − x2 + 3 ≡ 0 (mod 7)?

4. (BMT-2013-Discrete-4) Given f1 = 2x − 2 and k ≥ 2, define fk (x) = f1 (fk−1 (x)) to


be a real-valued function of x. Find the remainder when f2013 (2012) is divided by
the prime 2011.

40

You might also like