# euclid.py1#2# Author: Ralph Gootee <[email protected]>3#4# implementaions of the euclidean algorithm and the extended5# euclidean algorithm6#78from math import floor;910#-------------------------------------------------------------------------------11def gcd(a,b):12while b != 0:13t = b;14b = a % b;15a = t;16return a1718#-------------------------------------------------------------------------------19def xgcd(a,b):2021x = 0;22y = 1;23lastx = 1;24lasty = 0;2526while b != 0:2728temp = b;29quotient = int(floor(a / b));30b = a % b;31a = temp;32temp = x;33x = lastx -quotient*x;34lastx = temp;35temp = y;36y = lasty-quotient*y;37lasty = temp;3839return [lastx,lasty];40414243