So I have written
function gcd(a, b)
if b <> 0
gcd (b, a % b)
else
return a
print gcd (12, 9)
so it goes:
Could you please help me find my mistake?
I think you need this line:
return gcd (b, a % b)
instead of just:
gcd (b, a % b)
Here's my Python code showing the solution in action:
>>> def gcd(a,b):
... if b != 0:
... return gcd(b, a % b)
... else:
... return a
...
>>> print gcd(12,9)
3
>>>
This was with Python 2.4.3 on Linux.