Skip to content

Instantly share code, notes, and snippets.

@juanriaza
Created February 6, 2011 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanriaza/813592 to your computer and use it in GitHub Desktop.
Save juanriaza/813592 to your computer and use it in GitHub Desktop.
Algoritmo Euclides
def euclides(a,b):
return a if b == 0 else euclides(b, a%b)
def euclides_ext(a,b):
if b == 0:
return [1,0,a]
else:
x,y,d = euclides_ext(b, a%b)
return [y, x - (a//b)*y, d]
print euclides(112,70)
print euclides_ext(112,70)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment