Section 5.1 Solving Linear Congruences
ΒΆOur first goal to completely solve all linear congruences axβ‘b (mod n). The most important fact for solving them is as follows.Proposition 5.1.1.
The linear congruence
has a solution precisely when gcd(a,n)β£b.
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.
7xβ‘8 (mod 15)
6xβ‘8 (mod 15)
7xβ‘8 (mod 14)
6xβ‘8 (mod 14)
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,y\) to \(ax-b=ny\)
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 axβ‘b (mod n), we can construct all of them, and we know exactly how many there are.
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 \(t\) go from 0 to \(d-1\) will give all different solutions.
Example 5.1.4.
Let's solve
Here, gcd(a,n)=3 so we will have 3 solutions, all separated by nd=213=7.
We need one solution first. Trying by guess and check small values gives us
12(1)=12β’15,
12(2)=24β‘3β’15,
but 12(3)=36β‘15 (mod 21).
So we may take x=3 as our x0. Then we add 7 a couple times (mod 21) and we see that x=[3],[10],[β4] all work.
Alternately,
is the general solution.