Sunday, January 22, 2012

find least common multiple of 2 numbers.

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

1 comment:

  1. There is no need to check if(a==0) in calGCD because it is already checked in findLCM().

    Ali

    ReplyDelete