1# Function to find HCF the Using Euclidian algorithm
2def compute_hcf(x, y):
3 while(y):
4 x, y = y, x % y
5 return x
6
7hcf = compute_hcf(300, 400)
8print("The HCF is", hcf)
1# Python program to find H.C.F of two numbers
2
3# define a function
4def compute_hcf(x, y):
5
6# choose the smaller number
7 if x > y:
8 smaller = y
9 else:
10 smaller = x
11 for i in range(1, smaller+1):
12 if((x % i == 0) and (y % i == 0)):
13 hcf = i
14 return hcf
15
16num1 = 54
17num2 = 24
18
19print("The H.C.F. is", compute_hcf(num1, num2))
20