Modular inverse by Euler's theorem for Gaussian integers

133 Views Asked by At

To compute the multiplicative inverse modulo a prime one can use extended GCD or Euler's theorem:

$$x^{-1} = x^{p-2} \mod p$$

Is there similar formula for x being a Gaussian integer? I'm asking because

$$-i^{3-2} \mod 3 = -i$$

but Mathematica says:

PowerMod[-i, -1, 3] = i