You are on page 1of 1

The Extended Euclidean Algorithm has inputs integers a,b 1 and outputs integers X,Y such that aX+bY=d=gcd

d (a,b) is the greatest common divisor of a and b. Starting with A=(1,0,a), B=(0,1,b) the algorithm obtains a sequence of pairs of triples (x,y,z) of integers such that ax+by=z > 0. Given two successive triples A=(xA,yA,zA) and B=(xB,yB,zB) apply the Division Algorithm to the division of zA by zB, so that zA=qzB+r with quotient q and remainder r such that 0 r < zB . The next two triples are then defined by A=B, B=(xA,yA,zA)-q(xB,yB,zB) with the new zB=zA-qzB=r strictly less then the old zB. The algorithm terminates when the remainder is r=0, returning X=xB, Y=yB, d=gcd(a,b)=zB such that aX+bY=d.

You might also like