Solution of Linear Congruence/Number of Solutions

Theorem
Let $a x \equiv b \pmod n$ be a linear congruence.

Let $\gcd \left\{{a, n}\right\} = d$.

Then $a x \equiv b \pmod n$ has $d$ solutions which are given by the unique solution modulo $\dfrac n d$ of the congruence:
 * $\dfrac a d x \equiv \dfrac b d \mathop {\left({\bmod \, {\dfrac n d}}\right)}$

Proof
From Solution of Linear Congruence: Existence:
 * the problem of finding all integers satisfying the linear congruence $a x \equiv b \pmod n$

is the same problem as:
 * the problem of finding all the $x$ values in the linear Diophantine equation $a x - n y = b$.

From Integers Divided by GCD are Coprime:
 * $\gcd \left\{{\dfrac a d, \dfrac n d}\right\} = 1$

So the has a unique solution modulo $\dfrac n d$, say:
 * $x \equiv x_1 \mathop {\left({\bmod \, {\dfrac n d}}\right)}$.

So the integers $x$ which satisfy $a x \equiv b \pmod n$ are exactly those of the form $x = x_1 + k \dfrac n d$ for some $k \in \Z$.

Consider the set of integers $\left\{{x_1, x_1 + \dfrac n d, x_1 + 2 \dfrac n d, \ldots, x_1 + \left({d-1}\right)\dfrac n d}\right\}$.

None of these are congruent modulo $n$ and none differ by as much as $n$.

Further, for any $k \in Z$, we have that $x_1 + k \dfrac n d$ is congruent modulo $n$ to one of them.

To see this, write $k = d q + r$ where $0 \le r < d$ from the Division Theorem.

Then:

So these are the $d$ solutions of $a x \equiv b \pmod n$.