I am trying to write a Python program to find the greatest common divisor of two numbers in Python. I have been following the algorithm described here, but I am having trouble getting it to work.
When I run this code, I am getting an error:
I am not sure what I am doing wrong. Can anyone help me?
Thanks
Code:
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
Code:
Traceback (most recent call last):
File "gcd.py", line 4, in <module>
return a % b
ZeroDivisionError: division by zero
Thanks