(New page: 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...)
 
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
[[Category:MA453Spring2009Walther]]
 +
=Code for the Extended Euclid Algorithm=
 
This is the Extended Euclid algorithm we talked about last Thursday. Kind of cool, plug it into your favorite programming language.
 
This is the Extended Euclid algorithm we talked about last Thursday. Kind of cool, plug it into your favorite programming language.
  
Line 7: Line 9:
 
     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)]
 +
----
 +
[[MA453|Back to MA453]]
 +
 
 +
[[MA453_(WaltherSpring2009)|Back to MA 453 Spring 2009 Prof. Walther]]

Latest revision as of 06:16, 4 January 2011

Code for the Extended Euclid Algorithm

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)]

Back to MA453

Back to MA 453 Spring 2009 Prof. Walther

Alumni Liaison

Have a piece of advice for Purdue students? Share it through Rhea!

Alumni Liaison