Line 8: Line 8:
 
     else
 
     else
 
         [c,d] = eeuclid(b, a % b)
 
         [c,d] = eeuclid(b, a % b)
         return [y, x - y*(a/b)]
+
         return [d, c - d*(a/b)]

Revision as of 21:14, 3 January 2011

This is the Extended Euclid algorithm we talked about last Thursday. Kind of cool, plug it into your favorite programming language.


def eeuclid(a,b)

   if a % b = 0:
       return [0,1]
   else
       [c,d] = eeuclid(b, a % b)
       return [d, c - d*(a/b)]

Alumni Liaison

Ph.D. on Applied Mathematics in Aug 2007. Involved on applications of image super-resolution to electron microscopy

Francisco Blanco-Silva