Modular inverses
What is an inverse?
What is a modular inverse?
// X is the mod inverse of A
(A * X) β‘ 1 (mod M)
(A * X) mod M = 1
// X lies in range {1, 2, β¦ M-1}, within the range of M
// X cannot be 0 as A*0 (mod M) will never be 1
// The inverse exists only iff A and M are relatively prime (i.e. if gcd(A, M) = 1)Example
The Euclidean Algorithm
Last updated