Python program to find hcf of two numbers
TO FIND HCF OF TWO GIVEN NUMBERS
USING WHILE LOOP:
a=int(input("dividend"))
b=int(input("divisor:"))
rem=1
if a>b:
while rem>0:
if a%b==0:
print("HCF is",b)
break
else:
rem=a%b
a=b
b=rem
else:
print("dividend must be greater than divisor")
b=int(input("divisor:"))
rem=1
if a>b:
while rem>0:
if a%b==0:
print("HCF is",b)
break
else:
rem=a%b
a=b
b=rem
else:
print("dividend must be greater than divisor")
OUTPUT:
Comments
Post a Comment