Write a program to get LCM of two numbers using PHP?
Here is the program we can use to get LCM of two number using PHP.
BY Best Interview Question ON 11 Aug 2019
Example
// PHP program to find LCM of two numbers
// Recursive function to
// return gcd of a and b
function gcd( $a, $b)
{
if ($a == 0)
return $b;
return gcd($b % $a, $a);
}
// Function to return LCM
// of two numbers
function lcm( $a, $b)
{
return ($a * $b) / gcd($a, $b);
}
// Driver Code
$a = 15;
$b = 20;
echo "LCM of ",$a, " and " ,$b, " is ", lcm($a, $b);