Recall that the multiplicative inverse modulo n is found using the Bézout's identity. Also recall that the number of positive integers less than or equal to n that are relatively prime to n is given by the Euler's totient function.

For more, see Multiplicative group of integers modulo n.