Problem solving using Euclid Algorithm

Given two non-negative integers  and , we have to find their GCD (greatest common divisor), i.e. the largest number which is a divisor of both  and . It's commonly denoted by 

The Euclidean algorithm, discussed below, allows finding the greatest common divisor of two numbers a and b in 

This is a straight forward problem for which you just need to find the GCD and you will get the LCM by using the property that 
Product of two numbers = GCD(of those numbers)* LCM(of those numbers)
a*b = gcd(a,b)*lcm(a,b)
Below is the solution for this problem in which I have builtin function __gcd() to find gcd of two numbers which is using the Euclid Algorithm.

Thank You!
If you find any error or have any new method for solving the problem then do share through your comment.

Comments