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")

OUTPUT:







Comments

Popular posts from this blog

Python code to search a number in a sorted list

Sum of the digits present in a list