Table of Contents
Introduction
The task is to find the greatest common divisor (GCD) of two given numbers.
Program
def find(num1, num2): if num1 == 0 : return num2 return find(num2%num1, num1) num1 = int(input("Enter the first number:")) num2 = int(input("Enter the second number:")) print("Output: gcd({0},{1}) = {2} ".format(num1,num2,find(num1, num2)))
Output
Explanation
In Basic Euclidean Algorithm, we divide the smaller number and check if remainder is equalled to zero. The number is returned when remainder is found to be zero.
0 Comments