Answer to Question #3373 in Python for mukunda

Question #3373
Write a program to find the Greatest common divisor in recursive method
1
Expert's answer
2011-08-02T14:01:19-0400
def gcd_rec (a, b, x):
if a % x == 0 and b % x == 0:
& return x
return gcd_rec (a, b, x-1)

def gcd (a, b):
return gcd_rec (a, b, min(a,b)-1)

print(gcd(8,12))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS