I want to proof the following:
If an element $[a] \in \mathbb{Z}$/m$\mathbb{Z}$ is a unit, then $a$ and $m$ are coprime, i.e. $gcd(a,m) = 1$.
Proof:
Let $[a]$ be a unit and $[a]^{-1} = [b]$.
$\implies ab \equiv 1 \pmod m$
$\implies$ there is a $q \in \mathbb{Z}$ with $ab = qm+1$
$\implies ab-qm = 1$
$\implies \gcd(a,m)=1$
My question is: What is the reason that I am able to conclude the last step - $gcd(a,m) = 1$. Is it why I can divide the whole equation $ab-qm=1$ by a maximum of 1, because when I divide the equation by a number $> 1$, the right-hand-side would be a fraction and that is not allowed since we are in $\mathbb{Z}$. That was my guess but I am not sure at all.
Thanks for your answers.