Consider
$$kx \equiv a \bmod M$$
Where $x,a,M$ are known, solving for $k$. Let $g = \gcd(M,x)$. Why is it the case that if $g$ does not divide $a$, there is no solution?
Consider
$$kx \equiv a \bmod M$$
Where $x,a,M$ are known, solving for $k$. Let $g = \gcd(M,x)$. Why is it the case that if $g$ does not divide $a$, there is no solution?
If the solution exists, the congruence can be rewritten as $kx-a=Mj$ for some integer $j$. This implies $kx-Mj=a$. The left side is divisible by $g$. So for the equality to hold right side must also be divisible by $g$.