# How do I divide across equivalence in modular arithmetic

I understand how to solve for $k$ for something like $2k \equiv 4 \bmod 16$. This would become $k \equiv 2 \bmod 8$. But how would I solve for $k$ for something like $3k \equiv 1 \bmod 16$?

If you have $2k\equiv 4 \pmod {16}$, then for some integer $m$,
$$2k=16m+4$$ which means $k=8m+2$. Now if you have $3k\equiv 1\pmod{16}$, we can multiply by $5$ to get $$15k\equiv -k\equiv 5 \pmod {16}$$ and thus
$$k\equiv -5\equiv 11\pmod{16}$$ Or $k=16m+11$.
In general, $a$ has a multiplicative inverse mod $p$ iff $(a,p)=1$.