Extended Euclidean Algorithm
Extended Euclidean Algorithm
The greatest common divisor of two integers and can be found by the Euclidean algorithm by successive repeated application of the division algorithm. The extended Euclidean algorithm not only computes but also returns the numbers and such that . The remainder of the step in the Euclidean algorithm can be expressed in the form =a+b, where and can be determined from the corresponding quotient and the values ,, or , two rows above them using the relations =- and =-, respectively. This forward method requires no back substitutions and reduces the amount of computation involved in finding the coefficients and of the linear combination.
a
b
gcd(a,b)
s
t
gcd(a,b)=as+bt
r
i
th
i
r
i
s
i
t
i
s
i
t
i
q
i
s
i-1
s
i-2
t
i-1
t
i-2
s
i
s
i-2
q
i
s
i-1
t
i
t
i-2
q
i
t
i-1
s
t