Proving: $\exists! x \in \mathbb Z$ such that $ax ≡ b \pmod m,$ if and only if $\gcd(a,m)\mid b$ How can I  prove that: 

Let $a, b, m \in \mathbb{Z}$. There exists exactly one $x \in \mathbb{Z}$ with $ax ≡ b \pmod m$ if and only if $\gcd (a, m) \mid b$

 A: Well, for starters let's prove the following:
$ak \equiv bk \ (mod \ ck) \iff a \equiv b \ (mod \ c)$.
$Proof.$ If $ak \equiv bk \ (mod \ ck)$, 
$$ck \ | bk - ak  \Rightarrow bk - ak = (b-a)k = ck\cdot d$$ for some integer $d$. Finally, diving by $k$ (if $k$ is zero result is trivial, so we may aswell assume $k \neq 0$) gets us:
$$ b-a = cd $$
which by definition means 
$$ a \equiv b \ (mod \ c)$$
Reciprocally, 
$$ a \equiv b \ (mod \ c) \iff c | b - a \iff b - a = cd, \ d \in \mathbb{Z} \Rightarrow k(b-a) = kcd \iff kb - ka = kcd \iff kc | kb - ka \iff ak \equiv bk \ (mod \ ck)$$
Now it suffices to prove that there exist an inverse of $ a \ (mod \ c) \iff (a:c) = 1$, and in the cases where the gdc is not 1, you can use the previous proposition by dividing $a,b,c$ by $(a:c)$.
$(a:c) = 1$ if and only if there exist integers $m, n$ such that
$$an + cm = 1$$
This equation, $(mod \ c)$, tells us
$$an \equiv 1 \ (mod \ c)$$
So $a$ has an inverse, $n$, $mod \ c$.
Now, 
$$ ax \equiv b \Rightarrow nax \equiv nb \iff x \equiv nb \ (mod \ c)$$
Also, $n$ is unique mod c, there are infinite integers which will satisfy this condition.
Edit: I forgot the other implication, I'll prove it by contradiction:
If $(a:c) \not | b$ and we assume the equation has a solution, then using the definition of $mod$ and the fact that $(a:c)|c$ we get 
$$(a:c)|c \Rightarrow (a:c) | ax - b \Rightarrow (a:c) | b$$ 
which contradicts our hypothesis.
