Given two numbers m and n, write a method to return the first number r that is
divisible by both (e.g., the least common multiple).
LCM (a, b) = (a x b) / GCD(a, b)
Code input:
a=12, b=18
code output:
LCM is: 36
divisible by both (e.g., the least common multiple).
LCM (a, b) = (a x b) / GCD(a, b)
Code input:
a=12, b=18
code output:
LCM is: 36
There is no need to check if(a==0) in calGCD because it is already checked in findLCM().
ReplyDeleteAli