CSCI3310 Lecture 02
CSCI3310 Lecture 02
Solving Congruences
Associate Professor
Department of Mathematics,
Islamic University of Gaza
2022-2023, Semester
1
Linear Congruences
Definition:
A congruence of the form:
ax ≡ b(mod m),
Note:
Notice that we can translate the congruence a ≡ b mod m into
the equations a − b = mk or a = b + mk for some k ∈ Z .
Definition:
An integer a¯ such that
a¯a ≡ 1 mod m
is said to be an inverse of a modulo m.
Multiplicative inverses can be used to solve congruences.
If ax ≡ b mod m then a¯ax ≡ (a¯b) mod m and thus x ≡ (a¯b)
mod m.
Example 1:
► x = 3 and m = 7. Then x.5 = 15 ≡ 1 mod 7, so 5 is a
multiplicative inverse of 3 mod 7.
► x = 8 and m = 15. Then x.2 = 16 ≡ 1 mod 15, so 2 is
a multiplicative inverse of 8 mod 15.
Example 2:
Let m = 15. Find an inverse of 8 modulo 15.
Solution: In order to find an inverse of 8 modulo 15, we
check 8.k for k = 1, 2, 3, . . . , 14 (i.e., the positive
integers smaller than 15), and find that
1.8 = 8 /≡ 1(mod 15), ?? 15 ‡ (8 − 1)
2.8 = 16 ≡ 1(mod 15), ?? 15 | (16 − 1)
3.8 = 24 /≡ 1(mod 15), ?? 15 ‡ (24 − 1)
4.8 = 32 /≡ 1(mod 15), ?? 15 ‡ (32 − 1)
(k ≤ 14).8 = k.8 /≡ 1(mod
15), so 2 is an inverse of 8 modulo 15.
Example 3:
Let m = 15. Find an inverse of 7 modulo 15.
Solution: In order to find an inverse of 7 modulo 15, we
check 8.k for k = 1, 2, 3, . . . , 14 (i.e., the positive
integers
smaller than 15),
Now check for:
≤ 3
1
between 4 and 8
2
3 between 9 and 11
4between 12 and 14
What is your answer !!!!
Theorem 1:
If a and m are relatively prime integers and m > 1, then an
inverse of a modulo m exists. Furthermore, this inverse is
unique modulo m.
In other words, there is a unique positive integer a¯ less
than m that is an inverse of a modulo m and every other
inverse of a modulo m is congruent to a¯ modulo m.
Example 5:
Find an inverse of 3 modulo 7.
Solution: Because gcd(3, 7) = 1, by Theorem 1, an
inverse of 3 modulo 7 exists.
► Using the Euclidian algorithm: 7 = 2.3 + 1.
► From this equation, we get − 2.3 + 1.7 = 1, and
see that −2 and 1 are B´ezout coefficients of 3 and
7. Therefore, −2.3 ≡ 1(mod 7).
► Hence, −2 is an inverse of 3 modulo 7.
► Also every integer congruent to −2 modulo 7 is an
inverse of 3 modulo 7, i.e., 5 , -9, 12, etc.
Example 6:
Find an inverse of 101 modulo 4620.
Solution: First use the Euclidian algorithm to show that gcd(101, 4620) =
1.
Example 7:
Solve the linear congruence 3x ≡ 4 mod 7, and find the smallest positive
integer that is a solution of this congruence.
Solution: In Example 4, We found that 5 is an inverse of 3 modulo 7,
i.e,
5.3 ≡ 1 mod 7.
15x ≡ 20 mod 7.
x = 15x ≡ 20 ≡ 6 mod 7.
The smallest integer that solves the congruence is 6. Which means that
the solutions are the integers x such that x ≡ 6 mod 7. That is, all
integers of the form 6 + 7k (k ∈ Z ) will satisfy the congruence 3x ≡ 4
mod 7.
Dr. Bishr M. IquelanThe solutions,
(IUGaza) namely, are {. . . , −15, −8,
4.4-Solving −1, 6, 13,
1st Semester, 2022-2023 9 / 22
Examples of solving linear congruences
Example 8:
Find x such that 3x ≡ 7 mod 10.
Solution: You can easily show that 7 is an inverse of 3 modulo 10, i.e,
The smallest integer that solves the congruence is 9. Which means that
the solutions are the integers x such that x ≡ 9 mod 10. That is, all
integers of the form 9 + 10k (k ∈ Z ) will satisfy the congruence 3x
≡ 7 mod 10.
The solutions, namely, are {. . . , −11, −1, 9, 19,
29, . . . }.
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 10 / 22
Examples of solving linear congruences
Example 9:
Find x such that 3x ≡ 6 mod 12.
Solution: Oops. This time we don’t have a multiplicative inverse to
work with. So what to do?
Well, let’s take a look at what this would mean. If 3x ≡ 6 mod 12,
that means 3x − 6 is divisible by 12, so there is some k ∈ Z such that
3x − 6 = 12k. Now that we’re working in the integers, we can
happily divide by 3, and we thus obtain that x − 2 = 4k. Hence, we
have that x ≡ 2 mod 4 solves the desired congruence.
The solutions, namely, are {. . . , −5, −2, 2, 6, 10,
14, . . . }.
In general, we have that ax − b = ny for some y ∈ Z, and hence ax − ny =
b. This implies that we can find a solution to this congruence if and only if
gcd(a, n) | b.
Proposition 1
Let n ∈ Z, and let a, b ∈ Z. The congruence ax ≡ b mod n has a
solution for x if and only if gcd(a, n) | b.
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 11 /
Examples of solving linear congruences
Example 10:
Solve the linear congruence 19x ≡ 4 mod
141.
Solution:
First we find an inverse of 19 Consequently,
modulo 141
141 = 19.7 + 8 1=3−2
19 = 8.2 + 3 = 3 − (8 − 3.2) = 3.3 − 8
8 = 3.2 + 2 = 3.(19 − 8.2) − 8 = 3.19 − 7.8
3 = 2.1 + 1 = 3.19 − 7.(141 − 19.7) = −7.141 +
it follows that gcd(19, 141) 52.19
= gcd(19, 8) = gcd(8, 3) = Thus 52.19 ≡ 1 mod 141, and thus 52 is
gcd(3, 2) = gcd(2, 1) = an
inverse of 19 modulo 141.
1.► Now we multiply both sides of 19x ≡ 4 mod 141 by 52, and obtain
52.19x ≡ 52.4 = 208 mod 141
It follows that the solutions are the integers x satisfying
x = 52.19x ≡ 208 ≡ 67 mod 141.
That is, all integers of the form 67 + 141k (k ∈ Z ) will satisfy the
congruence 19x ≡ 4 mod 141.
The solutions, namely, are {. . . , −282, −215, −74, 67, 208,
349, . . . }.
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 12 / 22
The Chinese Remainder Theorem
► We=have
2 × shown
77 × 3that
+ 387× is
55the
× 6smallest
+ 10 ×positive
35 × 6integer
= 3552that
≡ 87 mod
is a
simultaneous solution. Check it! 385.
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 15 / 22
Examples of solving linear congruences
Example 13:
Find all solutions x, if they exist, to the system of equivalences:
2x ≡ 6 mod 14, 3x ≡ 9 mod 15, 5x ≡ 20 mod
60.
Solution:As in Example 9, we first wish to reduce this, where possible, using
the strategy outlined following the statement of Proposition 1. Since gcd(2,
14) = 2, we can cancel a 2 from all terms in the first equivalence to write x
≡ 3 mod 7. Likewise, we simplify the other two equivalences to reduce the
entire system to x ≡ 3 mod 7, x ≡ 3 mod 5, x ≡ 4 mod 12.
We can now use the Chinese Remainder Theorem: Set m = 7 × 5 × 12 = 420.
We have M 1 = m/7 = 60, M 2 = m/5 = 84, and M 3 = m/12 = 35. We now seek a
multiplicative inverse for each Mk modulo mk .
60 × 2 ≡ 4 × 2 ≡ 1 mod 7, ⇒ y1 = 2,
84 × 4 ≡ 4 × 4 ≡ 1 mod 5, ⇒ y2 = 4,
35 × 11 ≡ 11 × 11 ≡ 1 mod 12, ⇒ y3 = 11.
Therefore, our solution takes the form:
x = a1 M 1 y1 + a2 M 2 y2 + a3 M 3 y3
= 3 × 60 × 2 + 3 × 84 × 4 + 4 × 35 × 11 = 2908
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 16 /
Examples of solving linear congruences
Example 14 (Example 11 Re-visit Back Substitution):
Solution:If x ≡ 2 mod 3, then x = 3t + 2, where t ∈ Z. Substituting this
expression for x into the second congruence, we get
3t + 2 ≡ 3 mod 5,
and consequently 3t ≡ 1 mod 5. Since 2 is an inverse of 3 modulo 5, we
multiply both sides by 2 and obtain
3.2t ≡ 1.2 mod 5,
and consequently t ≡ 2 mod 5, which means t = 5u + 2, where u ∈ Z,
and thus x = 3(5u + 2) + 2 = 15u + 8.
Substituting this expression for x into the third congruence, we get
15u + 8 ≡ 2 mod 7,
and consequently 15u ≡ −6 ≡ 1 mod 7. Since 1 is an inverse of 15 module
7, it follows immediately that
u ≡ 1 mod 7,
which means u = 7v + 1, where v ∈ Z , and thus
x = 15(7v + 1) + 8 = 105v + 23.
Therefore, those integers x satisfy x ≡ 23 mod 105 are the solutions.
ap ≡ a mod p.
Example 15:
► 217 ≡ 21 mod 7
► But 216 /≡ 1 mod 7. Notice, 7 | 21.
Example 16:
Calculate 2345 mod 11.
Solution:
The number 2 is not divisible by the prime 11, so by
Fer- mat’s Little Theorem
210 ≡ 1 mod
2345 ≡
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 19 / 22
Fermat’s Little Theorem
Example 17:
Calculate 7222 mod 11.
Solution:
The number 7 is not divisible by the prime 11, so by
Fer- mat’s Little Theorem
710 ≡ 1 mod
7222
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 20 / 22
Fermat’s Little Theorem
Example 18:
The number 21000 is divided by 13. What is the remainder?
Solution:
By Fermat’s Little Theorem,
212 ≡ 1 mod
Since 21000 =
2100
0
≡ 1 × 2
50 400
≡ 1× 2 400
mod
13.
Dr. Bishr M. Iquelan (IUGaza) 4.4-Solving 1st Semester, 2022-2023 21 / 22
Fermat’s Little Theorem
Question
1 Find 2925 mod 11.