by BehindJava
Write a program to find HCF or GCD using Python
In this tutorial we are going to learn about writing a program to Find HCF or GCD using Python.
How to Find HCF or GCD using Python?
x = int(input("Enter first number: "))
y = int(input("Enter second number: "))
if x > y:
smaller = y
else:
smaller = x
for i in range(1,smaller + 1):
if((x % i == 0) and (y % i == 0)):
hcf = i
print("The H.C.F. of", x,"and", x,"is", hcf)