What elements have multiplicative inverses in the ring of integers mod n and how to find them