Extended Euclidean Algorithm



Time (sec)
  a=  
  b=  
    a and b must be positive  
  d=
 
  k=
  l=  
     
    Finds d,k,l so that:
d=GCD(a,b)=ak-bl
 
  q=
  r=  
     
    Finds q,r so that:
a=qb+r
0≤ r < b