Prove that the linear congruence $ax \equiv b ~(mod ~n)$ has a solution if and only if $d ~|~ b$, where $d = gcd(a, n)$. If $d ~|~ b$, then it has $d$ mutually incongruent solutions modulo $n$.
Definition: Let $a, ~b, ~n > 0$ be integers and $x$ be a variable then an equation of the form $ax \equiv b ~(mod ~n)$ is called a linear congruence, and an integer $x_{0}$ for which $a x_{0} \equiv b ~(mod ~n )$ is called a solution of an equation $ax \equiv b ~(mod ~n)$.
By definition, $a ~x_{0} \equiv b ~(mod~ n)$ if and only if $n ~|~ a x_{0} - b $ i.e. $a x_{0} - b = n y_{0} $ for some integer $y_{0}$· Thus, the problem of finding all integers that will satisfy the linear congruence $a x \equiv b ~(mod ~n)$ is identical with that of obtaining all solutions of the linear Diophantine equation $ax - ny = b$.
Theorem: The linear congruence $ax \equiv b ~(mod ~n)$ has a solution if and only if $d ~|~ b$, where $d = gcd(a, n)$. If $d ~|~ b$, then it has $d$ mutually incongruent solutions modulo $n$.
Proof: In last para, we have observed that the given linear congruence $ax \equiv b ~(mod ~n)$ is equivalent to the linear Diophantine equation $ax - ny = b$. From Theorem, The linear equation $ax - ny = b$ has a integers solution if and only if $d$ divides $b$, where $d = gcd(a,n)$. Moreover, if $x_{0},~ y_{0}$ is any particular solution of this equation, then all other solutions are
$x = x_{0} + (\frac{n}{d}) \cdot t$, $y = y_{0} - (\frac{a}{d}) \cdot t$, where $t$ is an arbitrary integer.
We will take values of $t$ from $0$ to $d-1$, i.e. $t = 0, ~ 1, ~2, ~3, ~ \cdots ~ d-1$, then we will get values of $x$ as follows
$x = x_{0} , ~x = x_{0} + (\frac{n}{d}), ~ x = x_{0} + (\frac{n}{d}) \cdot 2, ~x = x_{0} + (\frac{n}{d}) \cdot 3, \cdots\cdots,~~x = x_{0} + (\frac{n}{d}) \cdot (d -1 )$
We claim that these integers are incongruent modulo $n$. Suppose on the contrary that there are two integers which are congruent modulo $n$. Say
$x_{0} + (\frac{n}{d}) \cdot t_{1} \equiv x_{0} + (\frac{n}{d}) \cdot t_2 ~ (mod~ n)$
where $0 \leq t_1 < t_2 \leq (d - 1)$, then we would have
$(\frac{n}{d}) \cdot t_{1} \equiv (\frac{n}{d}) \cdot t_2 ~ (mod~ n)$
Since $gcd(\frac{n}{d}, n) = \frac{n}{d}$ by Theorem we can cancel the factor n/d and we will get the congruence $t_{1} \equiv t_2 ~ (mod~ \frac{n}{\frac{n}{d}})$, i.e. $t_{1} \equiv t_2 ~ (mod~ d)$.
This gives that $ d ~|~ t_2 - t_{1}$, But this is impossible in view of the inequality
$0 < t_{1} - t_2 < d$.
Now, we show that any other solution $x_{0} + \frac{n}{d} \cdot t$ is congruent modulo $n$ to one of the $d$ integers listed above. We apply the Division Algorithm to $t, ~d$ therefore there exist a quotient $q$ and remainder $r$, so we can write $t$ as
$t = q \cdot d + r$, where $0 \leq r \leq d - 1$. Hence
$x_{0} + (\frac{n}{d}) \cdot t = x_{0} + (\frac{n}{d}) \cdot (q ~d + r)$
$= x_{0} + n \cdot q + (\frac{n}{d}) \cdot r$
$\equiv x_{0} + (\frac{n}{d}) \cdot r ~(mod ~ n) $
with $xo + \frac{n}{d} \cdot r $ being one of our $d$ selected solutions. This ends the proof.