Extended Euclidean algorithm
ID: extended-euclidean-algorithm
The extended Euclidean algorithm also computes integers satisfying , as in Bézout's identity. Back-substitution in the calculation under the Euclidean algorithm givesThus solves . The linear Diophantine equation is solvable exactly when divides : necessity follows from common divisibility, and multiplying this identity proves sufficiency. For coprime integers , the coefficient of is a modular inverse of modulo , and the coefficient of is a modular inverse of modulo , when the respective modulus is greater than one.
New to topics? Read the docs here!