Q. Write a program to find the greatest common divisor between two numbers.

 

Answer =

 

def great(a , b) :
    if b == 0 :
        return a
    else :
        return great (b, a % b)

num1 = int (input("Enter the first number :- "))
num2 = int (input ("Enter the second number :- "))
print ("Greatest common divisor of ", num1 ,'&', num2, 'is' ,great(num1 , num2))

Output :-

Enter the first number :- 257
Enter the second number :- 638
Greatest common divisor of  257 & 638 is 1

>>>

Enter the first number :- 24
Enter the second number :- 240
Greatest common divisor of  24 & 240 is 24
>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post