# Python program that finds the highest common factor (HCF) of two given numbers:

## Python program that finds the highest common factor (HCF) of two given numbers:

``````num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))

# Find the smaller number
if num1 > num2:
small = num2
else:
small = num1

# Initialize variables
hcf = 0

# Find the HCF
for i in range(1, small + 1):
if num1 % i == 0 and num2 % i == 0:
hcf = i

print("The HCF of", num1, "and", num2, "is", hcf)
``````

The program prompts the user to enter two numbers using the input() function, and stores the values in the variables “num1” and “num2”. It then uses an if-else statement to find the smaller number out of the two numbers. Then it uses a for loop to iterate through the range of numbers from 1 to the smaller number (inclusive) and for each number, it checks if it is a common factor of both the numbers, if yes it assigns the current number to the variable “hcf”. At the end of the loop, it prints the HCF of the two numbers.