TITLE: An integer $a \pmod m$ has inverse if and only if $\gcd(a,m)=1$?
QUESTION [6 upvotes]: An integer $a \pmod m$ has inverse if and only if $\gcd(a,m)=1$?
Why is this? I tried understanding it from my notes but I don't get it.
A thorough explanation would be greatly welcome.
Thanks for all the answers so far. I think my biggest problem is understanding why $\gcd(a,m)\neq1 \Longrightarrow \not\exists a^{-1}$.

REPLY [2 votes]: $\exists\,x\in\Bbb Z\!:\, ax\equiv 1\pmod{\! m}\iff \exists\, x,y\in\Bbb Z\!:\, ax\!+\!my = 1\!\! \overset{\rm Bezout\!\!}\iff \gcd(a,m) = 1$
The first equivalence is by definition of congruence, the second by Bezout's gcd identity.