HCF is stand for Highest Common factor or Greatest Common. HCF or Greatest common Divisor of two or more integers. When at least one of them is not zero is the greatest integer that divides the number without a remainder.
Find the HCF to two integers 8 and 12.
The divisors of 8 are: 1,2,4,8.
Ther divisors of 12 are: 1,2,4,6,12.
4 is Greatest common divisor of 8 and 12.
def hcf(a, b) if a>b: smaller=a else: smaller=b for i in rang (1,smaller+1): if(a%1==0)and(b%1==0)): hcf=1 return hcf n1=int(input("Enter first number")) n2=int(input("Enter second number")) print("The HCF of",n1,"and",n2,"is",hcf(n1,n2))