Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import argv
- def egcd(a,b):
- c = a % b
- if c == 0:
- return (b,0,1)
- (r,x,y) = egcd(b,c)
- return (r,y, x - (y * (a/b)))
- def gcd(a,b):
- if a%b == 0:
- return b
- return gcd(b, a%b)
- def iGCD(a, b):
- print recursivo(a,b)
- c = a%b
- while True:
- print a,b,c
- (a, b) = (b, c)
- c = a%b
- if c == 0:
- return True
- if __name__=='__main__':
- print egcd(1,2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement