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.
- '''
- if a>b:
- x=b
- else:
- x=a
- # print('a=',a,'b=',b,'x=',x)
- def gcd(a,b,x):
- if x==1:
- print('if')
- print('a=',a,'b=',b,'x=',x)
- return x
- elif a%x==0 and b%x==0:
- print('elif')
- print('a=',a,'b=',b,'x=',x)
- return x
- else:
- print('else')
- x-=1
- gcd(a,b,x)
- return gcd(a,b,x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement