can i compute the inverse mod m by inverting the prime factors?

99 Views Asked by At

I have $a \in \mathbb{Z}/\mathbb{mZ}$ and $a = p_1 * p_2$ in $\mathbb{Z}$ ($p_i$ are primes).

Furthermore, it holds $gcd(a,m) = 1$, so there exists an $a^{-1} \in \mathbb{Z/mZ}$.

Would be ok to write $a^{-1} = (p_1 * p_2)^{-1} = p_1^{-1} * p_2^{-1} \mod m$?

If yes, why?

If no, please submit a counter-example.

I'm not able to find anything on Wikipedia or somewhere else.

By the way: I know that you normally use the extended Euclidian Algorithm to compute the inverse.