Least Common Multiple

This algorithm find the least common multiple of two integers.



									function GCD($a, $b)
{
	if ($a == 0)
		return $b;

	while ($b != 0)
	{
		if ($a > $b)
			$a -= $b;
		else
			$b -= $a;
	}

	return $a;
}

function LCM($a, $b)
{
	return ($a * $b) / GCD($a, $b);
}
								


Example

									$lcm = LCM(15, 12);
								


Output

									60