Вы находитесь на странице: 1из 3

# MODULE 2.

CONGRUENCE

2.2

Lecture 2

Lecture 2

Preamble: In this lecture, we will derive a necessary and sucient condition for existence of solutions of an equation of the form ax b mod n. We will also discuss
uniqueness of solutions.

## Keywords: linear congruence

2.2.1

Linear Congruence

## Let n be a positive integer. Consider the following linear congruence

ax b mod n,
where a is an integer which is not divisible by n. We want to nd all integers x which
satisfy the above congruence. It is clear that if r is a solution, so is any s r modulo n.
So by a solution we mean a congruence class mod n whose members satisfy the equation.
We would also like to know when we have a unique solution. If we look at a few examples,
we nd that it is possible to have linear congruence which has no solutions, only one
solution or more than one solutions. For example, the linear congruence
2x 5 mod 6
has no solution: if r is a solution, then 6 must divide 2r 5, which implies in particular
that 2r 5 must be even. But that is not possible as 2r is even but 5 is odd. Now
consider
2x 1 mod 3.
If we look at three congruence classes modulo 3, we nd that [0] and [1] are not solutions, but [2] is a solution. Therefore, this congruence has a unique equivalence class of
solutions. Now consider the congruence
4x 2 mod 6.
We can check the 6 elements of a complete residue system of 6, and observe that both
[2] and [5] are solutions.

We will rst nd a necessary and sucient condition for existence of solutions of a linear
congruence. Then we will investigate the number of inequivalent solutions.

31

MODULE 2. CONGRUENCE

Lecture 2

## THEOREM 2.10. The congruence

ax b mod n
has a solution if and only if gcd(a, n) divides b.
Proof: Let gcd(a, n) = d. First assume that the above congruence has a solution r.
Then,
ar b mod n
= n

(b ar)

= d

(b ar),

= d

(b ar + ar)

= d

b.

d|a

Conversely, suppose d divides b. We will now exhibit a solution for the above congruence.
We can write b = db1 for some integer b1 . By Euclids algorithm, we can nd integers
r1 and s1 such that
ar1 + ns1 = d
= b1 (ar1 + ns1 ) = db1
= a(b1 r1 ) + n(b1 s1 ) = b
= a(b1 r1 ) b mod n.

The examples that we saw above are consistent with the theorem. The congruence
2x 5 mod 6 had no solution as the gcd(2, 6) = 2 does not divide 5. But 2x 1 mod 3
has a solution as the gcd of 2 and 3 divides 1. In the third example too, the gcd of 4
and 6 divides 2, and we could nd solutions.
THEOREM 2.11. Consider the congruence
ax b mod n,
where the gcd(a, n) = d divides b. Let x0 be a solution. Then all the other solutions are
precisely given by the following set:
x0 , x 0 +

n
2n
(d 1)n
, x0 +
, , x0 +
.
d
d
d
32

MODULE 2. CONGRUENCE

Lecture 2

## Proof: It is a trivial exercise to verify that for all i with 0 i (d 1), x0 +

solution ax b mod n.

in
d

is a

Next, we show that any two distinct elements in the above set are inequivalent modulo
n. As d divides n, we can write n = dk for some integer k. Consider i, j such that
0 i, j (d 1). Then ,
in
jn
x0 +
mod n
d
d
in
jn
=

mod n
d
d
= ik jk mod dk
(n = dk)
x0 +

= dk

k(i j)

= d

(i j).

## But (d 1) (i j) (d 1), hence d | (i j) implies i = j. Thus, two distinct

elements in the above set can not be congruent modulo n.

We still have to show that any solution x1 must be congruent to one of the d elements
in the set modulo n. We have n = dk and a = da1 , where gcd(k, a1 ) = 1.
ax1 b ax0 mod n
=

dk

| da1 (x1 x0 )

x1

x1

= x0 + ik
n
= x0 + i .
d

## It is enough to consider the above integer i in the range {0, 1, , (d 1)}, as

i i mod d = x0 +

in
i n
x0 +
mod n. 
d
d

## COROLLARY 2.12. The congruence

ax b mod n
has a unique solution if and only if a and n are coprime.
In the examples that we have discussed in this lecture, we saw that 2x 1 mod 3 has a
unique solution, namely [2], as 2 and 3 are coprime. On the other hand, 4x 2 mod 6
has more than one solution, as 4 and 6 are not coprime.
33