Why do I get the answer 1 only to program to find divisor?

  function, input, output, python, variables

This is the program to find divisor of two numbers but the answer of any number I input comes out to be 1. Where am I going wrong?

def divisor(a,b):
    result=1
    for i in range(b,-1):
        if a%i==0 and b%i==0:
            result=i
            break

    return result

num=input("calculate HCF of: ").split(",")
print(divisor(int(num[0]),int(num[1])))

Source: Python Questions

LEAVE A COMMENT