Math106 Module 3
Math106 Module 3
1 Congruences
A congruence is nothing more than a statement about divisibility. The theory of congruences was
introduced by Carl Friedreich Gauss. Gauss contributed to the basic ideas of congruences and proved
several theorems related to this theory. Gauss introduces the concept of congruence and the notation
that makes it such a powerful technique (he explains that he was induced to adopt the symbol ≡ because
of the close analogy with algebraic equality). According to Gauss, “If a number n measures the difference
between two numbers a and b, then a and b are said to be congruent with respect to n; if not, incongruent.”
In this section we will introduce congruences and their properties. Then present solutions to linear
congruences which will serve as an introduction to the Chinese Remainder Theorem. Finally,we will
present some important congruence theorems derived by Fermat and Euler.
Definition: Let m ≥ 0. We we say that the numbers a and b are congruent modulo m, denoted by
a ≡ b (mod m), if a and b leave the same remainder when divided by m. The number m is the modulus
of the congruence. The notationa 6≡ b (mod m) means that they are not congruent.
Equivalently, we say that a is congruent to b modulo m if m|(a − b) where a and b are integers,that
is, if a = b + km where k ∈ Z.
1
because 3 − 24 = (−3)7, −31 − 11 = (−6)7, and −15 − (−64) = 7 · 7.
Given an integer a, let q and r be its quotient and remainder upon division by m, so that
a = qm + r 0≤r<n
Then, by definition of congruence, a ≡ r (mod m). Because there are m choices for r, we see that every
integer is congruent modulo m to exactly one of the values 0, 1, 2, · · · , m−1; in particular, a ≡ 0 (mod m)
if and only if m|a. The set of m integers 0, 1, 2, · · · , m − 1 is called the set of least nonnegative residues
modulo m.
−12 ≡ 2 − 4 ≡ 3 11 ≡ 4 13 ≡ 6 22 ≡ 1 82 ≡ 5 91 ≡ 0
all modulo 7. An observation of some importance is that any m integers form a complete set of residues
modulo m if and only if no two of the integers are congruent modulo m.
There are many common properties between equations and congruences. Some properties are listed
in the following theorem.
Theorem 3.1: Let a, b, c and d denote integers. Let m be a positive integer. Then:
1. a ≡ a (mod m)
2
Proofs: We will present some proofs of the given properties and the others are left as an exercise.
(2) If a ≡ b (mod m), then m|(a − b). Thus there exists integer k such that a − b = mk, this implies
b − a = m(−k) and thus m|(b − a). Consequently b ≡ a (mod m).
(3) Suppose a ≡ b (mod m) and b ≡ c (mod m). Then m|(a−b) and m|(b−c). Then there exist integers
x and y such that a − b = mx and b − c = my. Thus, a − c = a − b + b − c = mx + my = m(x + y).
Hence, there exists x + y ∈ Z such that a − c = m(x + y). So m|(a − c). Therefore, a ≡ c (mod m).
(8) Assume that a ≡ b (mod m) and c ≡ d (mod m). Then m|(a − b) and m|(c − d). Thus ∃x, y ∈ Z
such that a − b = mx and c − d = my. So
(a − b) + (c − d) = mx + my
=⇒ (a + c) − (b + d) = m(x + y)
(10) Assume that a ≡ b (mod m) and c ≡ d (mod m). Then m|(a − b) and m|(c − d). Thus ∃x, y ∈ Z
such that a − b = mx and c − d = my. Now, a = b + mx and c = d + my. Then
ac = (b + mx)(d + my)
=⇒ ac = bd + bmy + dmx + m2 xy
=⇒ ac − bd = bmy + dmx + m2 xy
=⇒ ac − bd = m(by + dx + mxy)
3
Another Proof :
There exists two integers k and l such that a − b = mk and c − d = ml and thus ca − cb = m(ck)
and bc − bd = m(bl). Note that (ca − cb) + (bc − bd) = ac − bd = m(kc − lb). Hence, m|(ac − bd).
Therefore ac ≡ bd(mod m).
Example:
9. Since 19 ≡ 3(mod 8) and 17 ≡ 9 (mod 8), then 19(17) = 323 ≡ 3(9) = 27 (mod 8).
With suitable precautions, cancellation can be allowed; one step in this direction, and an important
one, is provided by the following theorem Theorem 3.2:
m
(1) If a, b, c and m are integers such that m > 0, d = (m, c) and ac ≡ bc(mod m), then a ≡ b mod d .
Proof. Part 2 follows immediately from Part 1. For Part 1, if ac ≡ bc(modm),then m|(ac − bc) =
c(a − b). Hence there exists k such that c(a − b) = mk. Dividing both sides by d, we get
( dc )(a − b) = k m m c m m
d . Since d , d = 1, it follows that d |(a − b). Hence a ≡ b mod d .
0 0
Another Proof: Assume that ab ≡ ac(mod m) and (a, m) = d. Then d|a and d|m. So ∃a , m ∈ Z
0 0
such that a = a d and m = m d. Moreover, m|(ab − ac) and so ∃x ∈ Z such that ab − ac = mx.
Now,
a(b − c) = mx
0 0
=⇒ a d(b − c) = m dx
0 0
=⇒ a (b − c) = m x
0 0 0 0
a m
Thus m |a (b − c). Since (a, m) = d, it follows that d, d
= 1. That is, (a , m ) = 1. This implies
0
that m |(b − c) that is m m
d |(b − c). Therefore, a ≡ b mod d .
4
The following Corollary is a special case of part (2) in Theorem 3.2.
Corollary If ca ≡ cb (mod p) and p 6 |c, where p is a prime number, then a ≡ b (mod p).
Proof. Let n ∈ N and assume that a ≡ b (mod m). Then m|(a − b) and so ∃x ∈ Z such that a − b = mx
that is a = b + mx. Thus
an = (b + mx)n
nbn−1 (mx) n(n − 1)bn−2 (mx)2 n(n − 1)(n − 2)bn−3 (mx)3
an = bn + + + + · · · + (mx)n
1! 2! 3!
nbn−1 (mx) n(n − 1)bn−2 (mx)2 n(n − 1)(n − 2)bn−3 (mx)3
an − bn = + + + · · · + (mx)n
1!
n−1 2! 3!
(x) n(n − 1)bn−2 (mx2 ) n(n − 1)(n − 2)bn−3 (m2 x3 )
nb
an − bn = m + + + · · · + (mn−1 xn )
1! 2 6
nbn−1 (x) n−2 2 n−3
(m2 x3 )
where 1! + n(n−1)b 2 (mx ) + n(n−1)(n−2)b
6 +· · ·+(mn−1 xn ) is an integer. Hence m|(an −bn ).
Therefore an ≡ bn (mod m).
a≡b (mod m1 , m2 , · · · , mt )
Example 1: Consider the congruence 33 ≡ 15 (mod 9). Then 3 · 11 ≡ 3 · 5 (mod 9). Since gcd(3, 9) = 3,
Theorem 3.2 leads to the conclusion that 11 ≡ 5 (mod 3). Another illustration is given by the congruence
−35 ≡ 45 (mod 8), which is the same as 5 · (−7) ≡ 5 · 9 (mod 8). The integers 5 and 8 being relatively
prime, then we cancel the factor 5 to obtain a correct congruence −7 ≡ 9 (mod 8).
Solution: Note that 25 ≡ −9 (mod 41). Then (25 )4 ≡ (−9)4 (mod 41). In other words, 220 ≡ 81 · 81
(mod 41). But 81 ≡ −1 (mod 41), and so 81 · 81 ≡ 1 (mod 41). Using parts (2) and (4) of Theorem 3.1,
we have
220 − 1 ≡ 81 · 81 − 1 ≡ 1 − 1 ≡ 0 (mod 41).
Thus, 41|220 − 1.
Example 3: Find the remainder obtained upon dividing the sum 1! + 2! + 3! + 4! + · · · + 99! + 100! by
12.
5
Thus, for k ≥ 4,
k! ≡ 4! · 5 · 6 · · · k ≡ 0 · 5 · 6 · · · k ≡ 0 (mod 12).
≡9 (mod 12)
The binary system is most convenient for use in modern electronic computing machines, because
binary numbers are represented by strings of zeros and ones; 0 and 1 can be expressed in the machine
by a switch (or a similar electronic device) being either on or off.
We shall frequently wish to calculate the value ofak (mod n) when k is large. Is there a more efficient
way of obtaining the least positive residue than multiplying a by itself k times before reducing modulo
n? One such procedure, called the binary exponential algorithm, relies on successive squarings, with a
reduction modulo n after each squaring. More specifically, the exponent k is written in binary form,
j
as k = (am am−1 · · · a2 a1 a0 )2 , and the values a2 (mod n) are calculated for the powers of 2, which
correspond to the 1’s in the binary representation.
Solution: Note that the exponent 110 can be expressed in binary form as
110 = 64 + 32 + 8 + 4 + 2 = (1101110)2
j
Thus, we obtain the powers 52 (mod 131) for 0 ≤ j ≤ 6. Then we have
Now,
≡ 60 (mod 131).
Another calculation for 5110 (mod 131), we can consider the powers
6
Then we have
5110 = 596 · 512 · 52 ≡ 41 · 117 · 25 ≡ 60 (mod 131).
Exercises
3. What is the remainder when the following sum 15 + 25 + 35 + · · · + 995 + 1005 is divided by 4?
4. Use the binary exponentiation algorithm to compute both 1953 (mod 503) and 14147 (mod 1537).
9
5. Find the last two digits of the number 99 .
9
[Hint: 99 ≡ 9 (mod 10); hence, 99 = 99+10k ; notice that 99 ≡ 89 (mod 100).]
6. Give an example to show that a2 ≡ b2 (mod n) need not imply that a ≡ b (mod n).
(c) If a, b, m and n are integers such that m, n > 0, n|m and a ≡ b (mod m), then a ≡ (mod n).
a b n
(e) If a ≡ b (mod n) and the integers a, b, n are all divisible by d > 0, then d ≡ d (mod d ).
9. Show that if ai ≡ bi (mod m) for i = 1, 2, · · · , n, where m is a positive integer and ai , bi are integers
Pn Pn
for i = 1, 2, · · · , n, then i=1 a1 ≡ i=1 bi (mod m)
10. Show that f (a) ≡ f (b) (mod m) for all polynomials f (x) with integer coefficients.
2 Residue Classes
A set of integers containing exactly those integers which are congruent to fixed integer module m is
called a residue class module m.
7
Definition: Fix m > 0. The residue class class of a modulo m (or congruence class, or equivalence class
of a modulo m) is [a] = {x : x ≡ a(modm)}, the set of all integers congruent to a modulo m. Note that,
by definition, [a] is a set and so we denote
[a] = mq + a : q ∈ Z = {· · · , −2m + a, −m + a, a, m + a, 2m + a, · · · }
Example: Fix m = 4. Then the residues of 1 is given by [1] = {· · · , −7, −3, 1, 5, · · · }. Note that
Also, [2] = {· · · , −6, −2, 2, 6, · · · } and [3] = {· · · , −5, −1, 3, 7, · · · }. Hence, we can write Z4 = {[0], [1], [2], [3]}
as Z4 = {[8], [5], [−6], [11]}.
Definition: A complete residue system modulo m is a set of integers such that every integer is congruent
modulo m to exactly one integer of the set.
The complete residue system modulo m is the set of integers 0, 1, 2, · · · , m − 1. Every integer is
congruent to one of these integers modulo m.
Example 1: The set of integers 0, 1, 2, 3, 4 form a complete residue system modulo 5. Another complete
residue system modulo 5 could be 6, 7, 8, 9, 10.
Note that [0] = [7]. Thus the complete residue system is Z7 = {0, 1, 2, 3, 4, 5, 6}.
Definition: A reduced residue system modulo m is a set of integers ri such that (ri , m) = 1 for all i and
ri 6= rj (mod m) if i 6= j.
8
Proof: Assume that [a] = [b]. Note that a ∈ [a] because a ≡ a (mod m). Since [a] = [b], we have
a ∈ [b]. Thus a ≡ b (mod m).
Assume that a ≡ b (mod m). Suppose that x ∈ [a], so that x ≡ a(mod m). Since a ≡ b (mod
m), by transitivity of equivalence, x ≡ b (mod m), and so x ∈ [b]. Hence [a] ⊆ [b]. The argument
to show that if x ∈ [b] then x ∈ [a] is similar. Thus [b] ⊆ [a].
Exercises
3. Suppose that 6 ≡ −5 (mod 22). Find two integers a and b such that [a] = [b].
ax ≡ b (mod m)
where a, b are given integers and m is a positive integer.For a simple example, you can easily check by
inspection that the linear congruence 6x ≡ 4 (mod 10) has solutions x = 4, 9. Already we see a difference
from ordinary algebra and note that linear congruences can have more than one solution.
In this section, we will be discussing linear congruences of one variable and their solutions. We start
by defining linear congruences.
Definition: A congruence of the form ax ≡ b (mod m) where x is an unknown integer is called a linear
congruence in one variable.
Note that if x0 is a solution for a linear congruence, then all integers xi such that xi ≡ x0 (mod
m) are solutions of the linear congruence. Also, observe that ax ≡ b (mod m) is equivalent to a linear
Diophantine equation. That is, there exists y such that ax − my = b.
Theorem 3.6: Let a, b and m be integers such that m > 0 and let d = (a, m). If d does not divide
b, then the congruence ax ≡ b (mod m) has no solutions. If d|b, then ax ≡ b (mod m) has exactly d
incongruent solutions modulo m.
m
Definition: The set of incongruent solutions is given by x = x0 + d t, where t is taken modulo d.
9
Remark 1: If x0 is a solution of the congruence, then the general solution is
m
x ≡ x0 (mod )
d
Remark 2: If d = (a, m) = 1, then there is a unique solution modulo m for the equation ax ≡ b
(mod m).
Examples:
91 = 42(2) + 7
42 = 7(6) + 0
Thus (42, 91) = 7. But 7 6 | 50. Hence the given linear congruence has no solution.
Solution: Notice that (3, 6) = 3 and 3|12. Thus there are three incongruent solutions modulo 6.
We use the Euclidean algorithm to find the solution of the equation 3x − 6y = 12 As a result, we
get x0 = 6. The residue system of t is {0, 1, 2} since t is taken modulo 3. Hence the solutions are
6
x0 = 6 + 0=6
3
6
x1 = 6 + 1=8
3
6
x2 = 6 + 2 = 10
3
x0 ≡ 6 (mod 6)
x1 ≡ 8 ≡ 2 (mod 6)
x2 ≡ 10 ≡ 4 (mod 6)
or by Remark 1,
x≡6 (mod 2) =⇒ x = 6 + 2k, k ∈ Z.
That is
SS = {· · · , 0, 2, 4, 6, 8, 10, · · · }
3. Find all the solutions of the congruence 68x ≡ 100 (mod 120)).
10
Solution: Note that (68, 120) = 4 and 4|100. Now, we find x0 using the linear diophantine equation
68x − 120y = 100 =⇒ 17x − 30y = 25. We have
30 = 17(1) + 13
17 = 13(1) + 4
13 = 4(3) + 1
4 = 1(4) + 0
Thus
1 = 13 − 4(3)
1 = 13 − [17 − 13](3)
1 = −17(3) + 13(4)
1 = 17(−7) + 30(4)
1 = 17(−7) − 30(−4)
=⇒ 25 = 17(−175) − 30(−100)
That is
SS = {· · · , −205, −175, −145, · · · }
Definition: A solution for the congruence ax ≡ 1 (mod m) for (a, m) = 1 is called the modular inverse
of a modulo m. We denote such a solution by ā.
Then
48 = 7(6) + 6
7 = 6(1) + 1
6 = 1(6)
11
Now,
1=7−6
1 = 7 − [48 − 7(6)]
1 = 7 − 48 + 7(6)
1 = 7(7) − 48
=⇒ x = 7 + 48k, ∀k ∈ Z.
Exercises
In this section, we will solve systems of linear congruences in one variable. That is the systems of the
form
a1 x ≡ b (mod m1 )
a2 x ≡ b (mod m2 )
a3 x ≡ b (mod m3 )
..
.
an x ≡ b (mod mn )
The process of solving this system is the same as the ones we have presented in the previous section.
x ≡ 6 (mod 9)
Solution: For the first congruence x ≡ 8(mod12), note that x = 8 + 12k1 ∀k1 ∈ Z. Substituting to
12
the second congruence we have
8 + 12k1 ≡ 6 (mod 9)
12k1 ≡ −2 (mod 9)
12k1 ≡ 7 (mod 9)
Since (12, 9) = 3 and 3 6 |7, this system of linear congruences has no solutions.
x ≡ 6 (mod 13)
Solution: Note that x = 8 + 12k1 ∀k1 ∈ Z. Substituting to the second congruence we have
Since (12, 13) = 1 and 1|11 so there exists a solution. Now, we solve for x0 using the solution
12x − 13y = 1 we have
13 = 12(1) + 1
12 = 1(12) + 0
k1 ≡ 2 (mod 13)
Thus k1 = 2 + 13k2 and so x = 8 + 12k1 = 8 + 12(2 + 13k2 ) = 32 + 156k2 ∀k2 ∈ Z. Therefore the
general solution is given by
x ≡ 32 (mod 156).
Another Solution: For x ≡ 8 (mod 12). We have the solution x = 8 + 12k ∀k ∈ Z. Substitute to
the second congruence we have
13
But
−2 ≡ −k (mod 13)
=⇒ k = 2 + 13t
Hence
x = 8 + 12(2 + 13t)
x = 8 + 24 + 156t
x = 32 + 156t
=⇒ x ≡ 32 (mod 156)
4x ≡ 12 (mod 14)
Solution: For 5x ≡ 7 (mod 12), note that (5, 12) = 1 and 1|7. Also using division algorithm and
its reverse we have x0 = −1. Thus the solution is
Hence we have x = 11 + 12k ∀k ∈ Z. For 4x ≡ 12 (mod 14), we have x ≡ 3 (mod 7). Thus
Note that
−2k ≡ −8 (mod 7)
k≡4 (mod 7)
=⇒ k = 4 + 7t
14
Another Solution: Note that for 5x ≡ 7 (mod 12), x0 = 35. Then we have the solution
35 + 12k ≡ 3 (mod 7)
k ≡ 16 (mod 7)
=⇒ k = 16 + 7t
Hence
x = 35 + 12(16 + 7t)
x = 35 + 192 + 84t
x = 227 + 84t
In the previous section, we provide a solution to system of linear congruences. In this section, we
discuss the solution of a system of congruences having different moduli. An example of this kind of
systems is the following; find a number that leaves a remainder of 1 when divided by 2, a remainder of 2
when divided by three and a remainder of 3 when divided by 5. This kind of question can be translated
into the language of congruences. Thus we will present a systematic way of solving this system of
congruences.
Theorem 3.7: (The Chinese Remainder Theorem) Suppose that m1 , m2 , · · · , mn are pairwise
relatively prime. Let M = m1 m2 · · · mn . We define the numbers b1, b2 , · · · , bn by choosing y = bi as a
M
solution of mi y ≡ 1 (mod mi ) for i = 1, 2, 3, · · · , n
15
Then the general solution of the system
x ≡ a1 (mod m1 )
x ≡ a2 (mod m2 )
x ≡ a3 (mod m3 )
..
.
x ≡ an (mod mn )
Examples: Solve the following system of congruences using Chinese Remainder Theorem.
(1) x ≡ 5 (mod 7)
x ≡ 8 (mod 19)
(2) x ≡ 1 (mod 2)
x ≡ 2 (mod 3)
x ≡ 3 (mod 5)
a1 = 1 a2 = 2 a3 = 3
m1 = 2 m2 = 3 m3 = 5
=⇒ y = 1 =⇒ y = 1 =⇒ y = 1
=⇒ b1 = 1 =⇒ b2 = 1 =⇒ b3 = 1
16
Therefore, the solution is given by
(3) x ≡ 2 (mod 5)
x ≡ 4 (mod 3)
x ≡ 3 (mod 7)
a1 = 2 a2 = 4 a3 = 3
m1 = 5 m2 = 3 m3 = 7
=⇒ y = 1 =⇒ y = −1 =⇒ y = 1
=⇒ b1 = 1 =⇒ b2 = −1 =⇒ b3 = 1
x ≡ 8 (mod 15)
x ≡ 5 (mod 84)
Solution: The moduli in this problem are not pairwise relatively prime, so we can not apply the
Chinese remainder theorem directly, and it is possible that such a system has no solution. Since
10 = 2 · 5, 15 = 3 · 5 , and84 = 4 · 3 · 7 , the first congruence is equivalent to
Note that
x≡1 (mod 4) =⇒ x ≡ 1 (mod 2), x ≡ 1 (mod 2).
17
Therefore, the original system is equivalent to the following system:
x≡2 (mod 3)
x≡1 (mod 4)
x≡3 (mod 5)
x≡5 (mod 7)
a1 = 2 a2 = 1 a3 = 3 a4 = 5
m1 = 3 m2 = 4 m3 = 5 m4 = 7
=⇒ y = 2 =⇒ y = 1 =⇒ y = −1 =⇒ y = 2
=⇒ b1 = 2 =⇒ b2 = 1 =⇒ b3 = −1 =⇒ b4 = 2
In this section we present applications of congruences. We present Fermat’s theorem, also known as
Fermat’s little theorem, Wilson Theorem and the Euler-Fermat’s Theorem.
aφ(m) ≡ 1 (mod m)
Theorem 3.9: (Fermat’s Theorem) Let p be a prime and suppose that p 6 |a. Then
18
Thus
538 = 510·3+8
= (510 )3 (52 )4
≡ 13 · 34
≡ 81
≡4 (mod 11)
Theorem 3.10: ( Wilson’s Theorem) If p is a prime number, then p divides (p − 1)! + 1. That is,
Note that 100 ≡ −1 (mod 101), 99 ≡ −2 (mod 101) and 98 ≡ −3 (mod 101). Thus
101 = 6(16) + 5
6 = 5(1) + 1
5 = 1(5) + 0
1 = 6 + 5(−1)
1 = 6 + [101 + 6(−16)](−1)
1 = 101(−1) + 6(17)
19
Theorem 3.11: (Fermat’s Little Theorem) If p is a prime number and a is an integer, then
ap ≡ a (mod p)
aφ(m) ≡ 1 (mod p)
ap−1 ≡ 1 (mod p)
aap−1 ≡ a (mod p)
ap ≡ a (mod p)
Example: Use Fermat’s Little Theorem to find the remainder of the following.
Solution: Since 31 is prime, it follows by Fermats’ Little Theorem that 331 ≡ 3mod 7.
Solution: Since 35 is not prime, we use Fermat-Euler Theorem. Note that φ(35) = φ(5)φ(7) =
4(6) = 24. Then 224 ≡ 1 (mod 7). Also, 26 ≡ 1 (mod 7). Thus
It might be worthwhile to give an example illustrating the failure of the converse of Fermat’s theorem
to hold, in other words, to show that if an−1 ≡ 1 (mod n) for some integer a, then n need not be prime.
To verify this, we require a technical lemma.
Lemma. If p and q are distinct primes with ap ≡ a (mod q) and aq ≡ a (mod p), then apq ≡ a
(mod pq).
Example: Suppose we want to verify 2340 ≡ 1 (mod 341), where 341 = 11 · 31. Notice that
210 = 1024 = 31 · 33 + 1.
Thus,
211 = 2 · 210 ≡ 2 · 1 ≡ 2 (mod 31)
and
231 = 2(210 )3 ≡ 2 · 13 ≡ 2 (mod 11)
20
or
2341 ≡ 2 (mod 341).
Exercises
(a) 2x ≡ 5 (mod 7)
(b) 6x ≡ 5 (mod 8)
2x ≡ 1 (mod 5)
3. Use Chinese Remainder Theorem to solve the following systems of linear congruences.
x≡2 (mod 5)
6. Show that if a is an integer such that a is not divisible by 3 or such that a is divisible by 9, then
a7 ≡ a (mod 63).
21