Blogger Tips and TricksLatest Tips And TricksBlogger Tricks

Program to Find GCD of two Numbers in python


"Program to Find GCD of two Numbers"
print ("Program to find the GCD of two numbers")
a = int(input ("Enter the first Number: "))
b = int(input ("Enter the second Number: "))
a1=int(a)
b1=int(b)
while not (a1 == 0 or b1 == 0) :
        temp1= a1%b1
        a1,b1 = b1 , temp1
     
if a == 0:
    print ("The GCD of Give two number", (a,b) , "is : ", b1)
else :
    print ("The GCD of Give two number" ,(a, b)," is :" ,a1 )

No comments:

Post a Comment

Flag Counter