fork download
  1. def egcd(a, b):
  2. x,y, u,v = 0,1, 1,0
  3. while a != 0:
  4. q, r = b//a, b%a
  5. m, n = x-u*q, y-v*q
  6. b,a, x,y, u,v = a,r, u,v, m,n
  7. gcd = b
  8. return gcd, x, y
  9.  
  10. print( egcd(12,25))
Success #stdin #stdout 0.03s 9720KB
stdin
Standard input is empty
stdout
(1, -2, 1)