Write a program to find the gcd of two numbers.


Write a program to find the gcd of two numbers.

  1. def gcd(x,y):
        global ans
        if x>y:
            x,y=y,x
        rem=y%x    
        if rem != 0:
            gcd(rem,x)
        else:
             ans=x
        return ans
    a=int(input("Enter the number "))
    b=int(input("Enter the number "))
    print("The GCD is ")
    print(gcd(a,b)

OutPut:-

Post a Comment

0 Comments