Hello,
I’m having trouble with a code sample I’m working on for a Salesforce interview question for my job. The question is: “How do you find the greatest common divisor of two numbers using recursion?” I’m having difficulty getting the code to work.
I’ve included a sample of the code I’ve written below. I’m having trouble understanding the concept of recursion and how it applies here.
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
Any advice or help would be greatly appreciated. Thank you!