You are on page 1of 4

Lec10: Linear Congruences

22 March 2023, MATH4024-Number Theory, Lecturer: Prof A. Munagi

1 Definition and Solution of a Linear Congruence


A congruence of the form
ax ≡ b (mod m), (1)
where x is unknown, is called a linear congruence in one variable.
Note that if x = x0 is a solution of (1) and x1 ≡ x0 (mod m), then x1 is also a
solution since ax1 ≡ ax0 ≡ b (mod m). Thus if one member of a congruence class mod
m is a solution, then all members of this congruence class are solutions.
So when we ask “how many of the m congruence classes give solutions?” we also
mean “how many incongruent solutions are there mod m?”
We illustrate the idea from scratch using the following running examples.
E1. The congruence 7x ≡ 3 (mod 12)
has the single solution x ≡ 9 (mod 12)
[obtained by testing the integers x = 1, 2, . . . , 12]
E2. The congruence 12x ≡ 2 (mod 8)
is found to have no solution.
E3. The congruence 6x ≡ 9 (mod 15)
has three solutions x ≡ 4, x ≡ 9, x ≡ 14 (mod 15).

Returning to the general linear congruence we see that (1) implies m|(ax − b).
So ∃ y ∈ Z such that ax − b = my, that is,

ax − my = b. (2)

This shows that the solution of the congruence (1) is equivalent to the solution of the
linear Diophantine equation (2). So we can transfer known results to congruences.

1
Prof A. Munagi Linear Congruences MATH4024-Number Theory

First, we deduce from (2) that the linear congruence (1) is solvable only when
d = (a, m) divides b.
Examples: In E1 d = (7, 12) = 1 and 1 divides b = 3, so the congruence has solutions.
Also in E3 d = (6, 15) = 3 and 3 divides b = 9, so the congruence has solutions.
But in E2 d = (12, 8) = 4 and 4 does not divide b = 2, so the congruence has no
solutions, as already found.

Returning to Equation (2), suppose that d|b so that it is solvable. Then


a m b
x− y = (3)
d d d
which corresponds to the linear congruence
a b m
x≡ (mod ). (4)
d d d
Since (a/d, m/d) = 1 in (3), we can solve it as before. Recall that if a particular
solution of (3) is (x0 , y0 ), then the general solution has the form
m a
x = x0 + · t, y = y0 + · t ∀ t ∈ Z.
d d
Hence the general solution of the congruences (4) or (1) is
m
x ≡ x0 (mod ). (5)
d
The congruence (5) contains infinitely many solutions, but finitely many incongruent
solutions modulo m. If x0 is chosen to satisfy 0 < x0 < m/d, then all the incongruent
solutions modulo m are
m m m
x0 , x0 + , x0 + 2 , . . . , x0 + (d − 1) (mod m). (6)
d d d
The gist of our constructive discussion is summarized in the following theorem.
Theorem 1.1. Let a, b, m be integers such that m > 0. The congruence

ax ≡ b (mod m)

has no solutions if d = (a, m) does not divide b.


If d|b, the congruence has exactly d incongruent solutions modulo m given by (6).
In particular if (a, m) = 1, there is a unique solution.
We remark that the solutions in (6) are ‘minimal’ because of the choice of x0 . In
general any set of d integers of the form x0 + (m/d)t would suffice provided that t
ranges over a complete residue system modulo d. To see this, take any two solutions
x1 = x0 + (m/d)t1 , x2 = x0 + (m/d)t2 . Then

2
Prof A. Munagi Linear Congruences MATH4024-Number Theory

x1 ≡ x2 (mod m) ⇐⇒ x0 + (m/d)t1 ≡ x0 + (m/d)t2 (mod m)


⇐⇒ (m/d)t1 ≡ (m/d)t2 (mod m)
⇐⇒ t1 ≡ t2 (mod d).
Examples: In E1 d = (7, 12) = 1 so there is one solution.
In E3 d = (6, 15) = 3 and 3 divides b = 9, so we expect three solutions. Dividing
through the given congruence by d = 3 gives 2x ≡ 3 (mod 5) with the general solution
x ≡ 4 (mod 5). Hence the solutions are
x ≡ 4, x ≡ 9, x ≡ 14 (mod 15).
Note: solution of the ‘reduced’ congruence (as given in E1, or 2x ≡ 3 (mod 5) in E2)
generally requires conversion to a linear Diophantine equation with using the Euclidean
Algorithm. In several cases, one may also find the general solution by clever multipli-
cations and cancellations of the reduced congruence.

Modular inverses. We know that the special congruence ax ≡ 1 (mod m) has a


solution if and only if (a, m) = 1.
Definition. Given an integer a with (a, m) = 1, a solution of ax ≡ 1 (mod m) is called
an inverse of a modulo m.
Example: 9 and 7 are mutual inverses mod 31 since 7 · 9 ≡ 9 · 7 ≡ 63 ≡ 1 (mod 31).

If we know an inverse of a mod m, we can use it to solve the congruence


ax ≡ 1 (mod m) with (a, m) = 1.
Let a be an inverse of a mod m so that aa ≡ 1 (mod m). Then
a(ax) ≡ ab (mod m) which gives x ≡ ab (mod m).
Consider the congruence 7x ≡ 22 (mod 31).
Since (7, 31) = 1 and 9 is an inverse of 7 mod 31, we have
9 · 7x ≡ 9 · 22 (mod 31) or
x ≡ 198 ≡ 12 (mod 31).

Exercise 1. Let p be a prime. Prove that an integer a > 0 is its own inverse modulo
p if and only if a ≡ 1 (mod p) or a ≡ −1 (mod p).

Example: Solve 42x ≡ 90 (mod 156).


d = (42, 156) = 6 and 6|90. So there are d = 6 incongruent solutions.
Reduce the congruence by canceling the common factor: 7x ≡ 15 (mod 26).
Therefore, 7x − 26y = 15. Run the Euclidean Algorithm:
26 = 7 · 3 + 5, 5 = 26 − 7 · 3
7 = 5 · 1 + 2, 2 = 7 − 5 · 1 = 7 − (26 − 7 · 3) · 1 = 7 · 4 − 26 · 1
5 = 2 · 2 + 1, 1 = 5 − 2 · 2 = 5 = 26 − 7 · 3 − (7 · 4 − 26 · 1) · 2
=⇒ 1 = 26 + 26 · 2 − 7 · 3 − 7 · 8 = 26 · 3 − 7 · 11,
That is, 7 · (−11) + 26 · 3 = 1 which gives 7 · (−165) + 26 · 45 = 15.

3
Prof A. Munagi Linear Congruences MATH4024-Number Theory

So the general solution of the reduced congruence is x ≡ −165 ≡ 17 (mod 26).


Hence all solutions are given by 17 + 26t, t = 0, 1, 2, 3, 4, 5, that is,
x ≡ 17, 43, 69, 95, 121, 147 (mod 156).

Exercise 2. Solve the following congruences


(a) 35x ≡ 8 (mod 102)
(b) 19x ≡ 8 (mod 140)
(c) 144x ≡ 216 (mod 360)
(d) 221x ≡ 111 (mod 360)
(e) 20x ≡ 7 (mod 15)
(f) 315x ≡ 11 (mod 501)
(g) 360x ≡ 3072 (mod 96).

You might also like