Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def gcdIter(a, b):
- '''
- a, b: positive integers
- returns: a positive integer, the greatest common divisor of a & b.
- '''
- # Your code here
- global x
- global y
- if a>=b:
- x=a
- y=b
- else:
- x=b
- y=a
- if x%y==0:
- return y
- else:
- while x%y>=0 or y%y>=0:
- y=y-1
- if a%y==0 and b%y==0:
- return y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement