Solving Linear Congruences
Lesson · Intermediate
Number Theory
Solution 1
Solution 2
There are infinitely many ways, but all of them try to achieve the common goal of reducing the coefficient of x.
Solution 1
Solution 2
Let
(⇒)
Suppose
Then
so
for some integer k. Since d | a and d | n,
(⇐)
Suppose
Write
Then
is equivalent to
where
Thus, it is enough to consider the case
Consider
Suppose two of them have the same remainder modulo n. Then, for some 1 ≤ i < j ≤ n,
Hence
Since
we have
But
which is impossible.
Therefore, a, 2a, ..., na have n distinct remainders modulo n. Hence, they cover all possible remainders
In particular, one of them has remainder b. Therefore, for some x,
Thus,
Consider
and let
Then:
If d ∤ b, there are no solutions.
If d | b, there are exactly d incongruent solutions modulo n.
Let
If
then by the solvability theorem for linear congruences,
has no solution.
Now suppose
Write
Then
is equivalent to
where
Therefore, modulo n', there is exactly one solution. Let this solution be
Thus all integer solutions are
for integers k.
Since
consider
These are all solutions modulo n.
They are pairwise incongruent modulo n. Indeed, if
then
Since n = dn',
But for
we have
which is impossible.
Hence these d solutions are distinct modulo n.
Therefore,
So altogether,
If
then x is called a multiplicative inverse of a modulo n.
Such an inverse exists if and only if
For example,
Since
we have
Then you can extend this immediately to solving
by multiplying by the inverse:
Solve
First compute
Since
solutions exist.
Divide by 6:
Divide by -4:
Find all integers n for which
has a solution.
A solution exists if and only if
Since
we need
Therefore,
Find the least positive integer x satisfying
Multiply by 2:
Multiply by 14: