[Math] Existence & uniqueness of solutions of linear congruences $\ cx\equiv b\pmod m$

elementary-number-theorymodular arithmetic

Prove that one can solve the congruence $cx \equiv b \pmod m \Longleftrightarrow \gcd(c,m)|b$. Show, moreover, that the answer is unique $\bmod{m/\gcd(c,m)}$

My Work

Proof of $(\Rightarrow)$:

Assume that $cx \equiv b \pmod m$ has a solution, call it $x_1$. Let $d = \gcd(c,m)$ Then
\begin{align*}
cx_1 \equiv b \pmod m &\Longleftrightarrow m | (cx_1 – b) \\
&\Longleftrightarrow cx_1 = km + b, \quad k \in \Bbb Z \\
&\Longleftrightarrow cx_1 + (-k)m = b \\
\end{align*}
As the $\gcd$, $d$ divides all linear combinations of $c$ and $m$, so $d | b$.

Proof of $(\Leftarrow)$:

Assume $d | b$. Then $b = dn$ for some $n \in \Bbb Z$. As the $\gcd$, $d = cs + mt$ for some $s,t$. So
\begin{align*}
dn &= csn + mtn \\
b &= csn + mtn \\
csn – b &= (-tn)m \\
csn – b &\equiv 0 \pmod m\\
csn &\equiv b \pmod m
\end{align*}

Taking $x = sn$, we have a solution to the linear congruence $cx \equiv b \pmod m$.

My Question

I am not sure how to prove uniqueness from here. Should I say that $cx \equiv b \pmod m$ gives that, for $d = \gcd(c,m)$, $$m | (cx -b ) \Longrightarrow \left({m \over d}\right) \mid \left({cx – b \over d}\right) = {c \over d}x – {b \over d}$$ However, I'm not sure how to move from here to uniqueness. I have that ${c \over d}x = {m\over d}k + {b\over d}$, but this doesn't seem to be much.

Best Answer

Hint $ $ If $ \,x,y\,$ are solutions then $ \ cx\equiv b\equiv cy\pmod{\! m}\ $ so, defining $ \ d=(m,c)\,$ we have

$$ \,m\,|\,c\,(x\!-\!y) \iff \color{#0a0}{\frac{m}d}\,\bigg|\,\color{#0a0}{\frac{c}d}\,(x\!-\!y)\color{#C00}{\iff} \frac{m}d\,\bigg|\ x\!-y,\ \ {\rm by} \ \ \left(\color{#0a0}{\frac{m}d,\frac{c}d}\right)\color{#90f}{= \frac{(m,c)}d} = 1\qquad$$

Remark $\ $ The final $ $ '$\color{#C00}{\!\!\iff}\!\!$' $ $ employs $\rm\color{#0a0}{Euclid's\ Lemma}$ and the $\rm\color{#90f}{\rm distributive\ law}$ for GCDs.

Alternatively $\ $ Bezout yields: $ \, d = (c,m) = j\:\!c+k\:\!m,\,\ j,k\in\Bbb Z.\,$ Let $ \,z = x-y.\,$ Then

$\!\bmod m\!:\ \color{#0a0}{cz\equiv 0\equiv mz}\ \Rightarrow\ dz = (c,m)z = j\:\!\color{#0a0}{cz}+k\:\!\color{#0a0}{mz \equiv 0},\,$ so $ \ m\,|\,dz\,\Rightarrow\,m/d\,|\,z$

Intuitively see this answer for an approach using modular fractions.

Related Question