Let $a$ and $n$ be positive integers, and let $d = \gcd(a, n)$. Show that the equation $ax\equiv 1 \pmod{n}$ has a solution for some integer $x$ if and only if $d = 1$".
I know that if $ax\equiv 1 \pmod{n}$, then $ax=nu+1$ giving $1=ax-nu$, meaning $d=1$. However, I'm not sure what to do for proving the other direction. Any help is appreciated.
By Euler's Theorem , $a^{\phi(n)} = 1 (\mathrm{mod}~n)$ if $n$ and $a$ are co-prime. Thus, you can directly take $x = a^{\phi(n) - 1}$ to satisfy the equation.