Calculate the multiplicative inverse in modular arithmetic
The number for which to find the modular inverse
The modulus must be a positive number
The modular multiplicative inverse of a number a
modulo m
is a number x
such that: (a × x) ≡ 1 (mod m)
For example, the modular inverse of 3 modulo 7 is 5 because:
(3 × 5) = 15 ≡ 1 (mod 7)
a
and m
are coprime (their greatest common divisor is 1).