public
Created

Algoritmo Euclides

  • Download Gist
gistfile1.py
Python
1 2 3 4 5 6 7 8 9 10 11 12
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)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.