Extended Euclidean Algorithm definition
The extended Euclidean algorithm finds both the greatest common divisor of two integers and coefficients that express it as a linear combination of them.
Extended Euclidean Algorithm in a picture
How it works
Use the Euclidean algorithm to compute successive remainders. Start with the last nonzero remainder and substitute earlier remainder equations in reverse order until only the original numbers remain. The coefficient of a gives an inverse of a modulo b when the gcd is 1 and b > 1.
Worked examples
Express gcd(20, 12) in terms of 20 and 12.
20 = 12 + 8 and 12 = 8 + 4, so 4 = 12 − (20 − 12) = 2·12 − 20.
Find an inverse of 4 modulo 11.
Since 1 = −11 + 3·4, the inverse is 3.
Find the gcd and coefficients for 15 and 9.
15 = 9 + 6 and 9 = 6 + 3, so gcd = 3 = 2·9 − 15.
Common mistake
Check the coefficients by multiplying by the original numbers and adding the two products.
Quick check
Which remainder gives the gcd?
Show answer
The last nonzero remainder.
What else does the extended algorithm give?
Show answer
Two integer coefficients.
What property allows the coefficients to give a modular inverse?
Show answer
The greatest common divisor is 1.
Sources
Flashcard
Extended Euclidean Algorithm
Reveal the definition
The extended Euclidean algorithm finds both the greatest common divisor of two integers and coefficients that express it as a linear combination of them.
Effortless Math. “Extended Euclidean Algorithm.” Math Dictionary.



