Write a python function that takes in two numbers and returns their HCF


Topic: Write a python function that takes in two numbers and returns their HCF

Solution

def hcf(num1, num2):
    smaller = num1 if num1 < num2 else num2
    for i in range(1, smaller+1):
        if (num1 % i == 0) and (num2 % i == 0):
            hcf = i
    return hcf



List all Python Programs