Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

What are the causes of errors when computing the (GCD) of two numbers using Python

I am encountering a problem when I attempt to execute my code that is meant to calculate the greatest common divisor of two values. When I run the program, I get an error message stating that the function 'gcd' is not defined.

def GCD(12,4):
    gcd = 1
    for i in range(2, max(12,4)/2):
        if((12 % i == 0) and (4 % i == 0)):
            gcd = i
    return gcd
Sign In or Register to comment.