An integer $a \pmod m$ has inverse if and only if $\gcd(a,m)=1$? 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}$.
 A: If $\gcd(a,m)=1$, then we can find an $x$ and $y$ such that $ax+my=1$ through the Euclidean algorithm. Thus $ax =1-my \equiv 1 \pmod{m}$. Thus $a$ has an inverse.
Conversely, if $a \pmod{m}$ has an inverse then there exists an $x$ such that $ax \equiv 1 \mod{m}$, which is the same as saying that exists a $y$ such that $ax = 1+my$ or $ax-my=1$, which implies, by the Euclidean algorithm, that $\gcd(a,m)=1$
A: Everything is based on Bézout's theorem: 
$$\gcd(a,m)=1\iff \exists\, u,v\in\mathbf Z\enspace \text{such that}\enspace ua+vm=1$$
This theorem shows that, if $\gcd(a,m)=1$, then $vm\equiv 1\mod a$.
Conversely, if  $\,vm\equiv 1\mod a$, it means there exists $u\in\mathbf Z$  such that $vm=1+ua$, whence $-ua+vm=1$, so that $\gcd(a,m)=1$.
A: $\exists x \in \mathbb{Z}$ s.t. $ ax \equiv 1$ mod $m \iff \exists n \in \mathbb{Z}$ s.t. $ax - nm = 1$.
Then if we let $d = gcd(a,m)$:
$d$ $| a$ and $d$ $| m$ so $d$ $|(ax-nm)$ and thus $d$ $|1$ and so $d = 1$
Conversely if $ d = 1$, be Bézout's Lemma, we can find $n,x \in \mathbb{Z}$ s.t. $ax - mn = 1$ as required.
A: $\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.
A: We may use computation modulo $10$ as an example.
The numbers $a$ that are not prime to $10$ are the even numbers, and the multiples of $5$. An inverse of $a$ modulo $10$ is any number $a'$ such that $a a' \equiv 1 \pmod{10}$; or, $aa'$ ends with the digit $1$.
Now, do you see why for an even number $a$, it is impossible to find $a'$ such that $aa'$ ends with $1$ ? And for $a$ multiple of $5$ ?
This generalizes nicely to a proof of: if $d=\gcd(a,m) \neq 1$, then $a$ is not invertible modulo $m$; namely, for any $a'$, $d$ divides both $aa'$ and $m$, and therefore, for any $a'$ and $t$, $aa' - t m$. This implies that $aa' - t m$ will always be $\neq 1$; or, that $aa' \not \equiv 1 \pmod{m}$.
For the converse direction, it is a bit less obvious but not harder. Namely, you should by now know the Bézout identity: namely, if $d = \gcd (a,m)$, then there exist $a', m'$ such that $aa' + mm' = d$. If $d = 1$, then this immediately means that $aa' \equiv 1 \pmod{m}$.
A: if $a$ has an inverse called $x$, we have $ax=1\mod m$ so there is linear combination of $a$ and $m$ that equals 1.
other side:if we have a linear combination of $m$ and $a$ that equals 1 ,the inverse of $a$ is exactly the coefficient of $a$.  
A: @Mastrel has the right of it, but I thought I'd provide an alternative way of showing that if $(a,m) = d \neq 1$ then $a$ is not invertible modulo $m$ that doesn't depend on the Euclidean algorithm or Bezout's theorem. Under this assumption, I know that $a = bd$ and $m = nd$ for some $b,n \geq 2$ such that $n < m$. Thus $an = bm$ is a multiple of $m$ and as such $an \equiv 0 \pmod m$. Suppose then that there exists $x$ such that $ax \equiv 1 \pmod m$. Then $m \mid (ax-1)$, and thus $m \mid n(ax-1) = anx-n$. But we know that $an$ is a multiple of $m$, whence $m \mid anx$ and therefore $m \mid n$. This is a contradiction since $2 \leq n < m$.
This is also roughly the idea behind a more general fact in abstract algebra, namely that in a ring with $1 \neq 0$ an element cannot be both a zero divisor and a unit.
