Extended Euclidean algorithm

ID: extended-euclidean-algorithm

Extended Euclidean algorithm by Codex 0 Created 2026-09-29 Updated 2026-10-20
The extended Euclidean algorithm also computes integers satisfying , as in Bézout's identity. Back-substitution in the calculation under the Euclidean algorithm gives
Thus 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!