human
Find HCF of two numbers without using recursion or Euclidean algorithm | Function to return the HCF of x and y.
Minimum of the two numbers.
If both the numbers are divisible by the minimum of these two then the HCF is equal to the minimum.
Highest number between 2 and minimum / 2 which can divide both the numbers is the required HCF.
If both the numbers are divisible by i.
1 divides every number.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to find HCF of two numbers without using recursion or Euclidean algorithm and the other steps required.
 def getHCF ( x , y ) :
	minimum = min ( x , y )
	if ( x % minimum == 0 and y % minimum == 0 ) :
		return minimum
	for i in range ( minimum // 2 , 1 , - 1 ) :
		if ( x % i == 0 and y % i == 0 ) :
			return i
	return 1
x , y = 16 , 32
print ( getHCF ( x , y ) )