My assignment is the following:
Prove that the system $$x\equiv a \pmod m$$ $$x\equiv b \pmod n$$ has a solution if and only if $\gcd(m,n) \mid (a-b)$
My approach is the following:
[$\longleftarrow$] Let $x=a +r_1m = b + r_2n$, where $r_1$ y $r_2$ are whole numbers. So, $a-b=r_2n-r_1m\ (*)$. If we find $d=$ GCD$(n,m)$, then $$n=N\cdot d$$ $$m=M\cdot d$$ Replacing in $(*)$ $$a-b=d(r_2N-r_1M)$$
[$\longrightarrow$] If $d=\gcd(n,m)$ and $d \mid a-b$, so $$d=\dfrac{n}{N}$$ $$d=\dfrac{m}{M}$$ and $\dfrac{n}{N}\Big |a-b$ y $\dfrac{m}{M}\Big |a-b$
How can I finish both sides of this proof?