Section 5.1 Solving Linear Congruences
Our first goal to completely solve all linear congruencesProposition 5.1.1.
The linear congruence
has a solution precisely when
Example 5.1.2.
Before going on, test yourself by checking which of the following four congruences has a solution and which ones don't.
(mod ) (mod ) (mod ) (mod )
Proof of Proposition 5.1.1.
The proof is pretty straightforward, as long as we recall when linear Diophantine (integer) equations have solutions.
The following are clearly equivalent:
Solutions \(x\) to \(ax\equiv b\) (mod \(n\))
Solutions \(x\) to \(n\mid ax-b\)
Solutions \(x\) to \(ax-b=ny\) (for some \(y\in\mathbb{Z}\))
Solutions \(x,y\) to \(ax-ny=b\)
And we know from Theorem 3.1.2 that this final equation has solutions precisely when \(\gcd(a,n) \mid b\text{.}\)
Proposition 5.1.3.
If we can construct one solution to the linear congruence
Proof.
Consider the proof of Proposition 5.1.1 above. We don't care about \(y\) (other than that it exists, and it does). So if we have one solution to the congruence, that is the same as having a solution \(x_0,y_0\) to the equation \(ax-ny=b\text{.}\)
But we already know what solutions to that look like, from Theorem 3.1.2. Looking just at the \(x\) components, the solutions from e.g. Subsection 3.1.3 (using \(k\) since \(n\) is taken) are
This argument also gives us the exact number of solutions (modulo \(n\)), because letting \(k\) go from 0 to \(d-1\) will give all different solutions.
Example 5.1.4.
Let's solve
Here,
We need one solution first. Trying by guess and check small values gives us
but
(mod ).
So we may take
Alternately,
is the general solution.
Remark 5.1.5.
The previous example well illustrates that, while there are infinitely many integers which may solve a congruence, we will usually only consider the finitely many classes of solutions (or finitely many remainders, if you like). However, it is easy to be sloppy and talk about one when you mean the other, so be cautious.