Solving $ax+b$ (mod n) = $cx+d$ (mod n) How does one solve questions of $ax+b$ (mod n) = $cx+d$ (mod n) form?
I know that if $b,d$ are $0$ then, I can take multiples of $n$ as solutions for x.
but what if $b,n$ are not zero? 
Under what conditions do solutions exist?

$$ ax + b \pmod n \equiv cx + d \quad \pmod n $$
$$ (a - c)x \equiv d-b \pmod n$$
$$ Ax \equiv B \quad \pmod n$$
where $A  = a-c, \; B = d - b$. Thus,
1) If $ a \equiv c \pmod n$:


*

*If $b \equiv d \pmod n$: $x$ is any integer.

*Otherwise, no solution.


2) If $a \not\equiv c \pmod n$:


*

*If $A$ has a multiplicative inverse$\pmod n$ called C, the solution will be:
$ x \equiv BC \pmod n$.

*Otherwise, no solution.


Note the multiplicative inverse$\pmod n$ can be found by tabulating the product of $ij$ in a square table where the rows are numbered $i = 0,1,...,n-1$ and the columns are numbered $j=0,1,...n-1$. To find the multiplicative inverse of each $i$, find the value of $j$ that makes $ij \equiv 1\pmod n$. In general, not all $i$ have a multiplicative inverse.
