Oct-05-2020, 07:47 PM
(This post was last modified: Oct-05-2020, 07:47 PM by deanhystad.)
Does GCD stand for Greatest Common Denominator? Is there any chance that this is how the code is supposed to work?
def gcd(x,y): if x > y: return gcd_helper(x, y, y) else: return gcd_helper(x, y, x) def gcd_helper(x, y, f): if x % f == y % f == 0: return f else: return gcd_helper(x, y, f-1) print(gcd(3,2))If so it would be faster and simpler to replace the helper function with a loop.