This function is only available in PHP 7.3.0 or later
Least common multiple - from Wikipedia
Algorithm for Computing the LCM
LCM Calculator - Least Common Multiple
<?php
GMP gmp_lcm ( GMP|int|string $num1,
GMP|int|string $num2 )
where,
$num1 = The first value to get the LCM
$num2 = The second value to get the LCM
?>
<?php
// Try this code several times
if ((PHP_VERSION_ID < 70300))
die('This function is not available.');
$a = gmp_random_range(PHP_INT_MIN, PHP_INT_MAX);
$b = gmp_random_range(PHP_INT_MIN, PHP_INT_MAX);
// You must try other values for gmp_random_range
$lcm01 = gmp_lcm($a, $b);
echo 'gmp_lcm( ' . $a .', ' . $b . ' ) = ' . $lcm01;
?>
<?php
if ((PHP_VERSION_ID < 70300))
die('This function is not available.');
$a02 = (idate('Y') * -1);
$b02 = 204;
// You must try other values
$gcd02 = gmp_lcm($a02, $b02);
echo 'gmp_lcm( ' . $a02 .', ' . $b02 . ' ) = ' . $gcd02 . '<br><br>';
?>
<?php
if ((PHP_VERSION_ID < 70300))
die('This function is not available.');
echo "gmp_lcm(100, 77) = " . gmp_lcm(100, 77) . '<br><br>';
echo "gmp_lcm(99, 77) = " . gmp_lcm(99, 77) . '<br><br>';
echo "gmp_lcm(99, -77) = " . gmp_lcm(99, -77) . '<br><br>';
echo "gmp_lcm(-99, -77) = " . gmp_lcm(-99, -77) . '<br><br>';
// You must try other values for each gmp_lcm
var_dump(gmp_lcm(gmp_init(99), gmp_init(77)));
echo "gmp_lcm(gmp_init(99), gmp_init(77)) = " .
gmp_lcm(gmp_init(99), gmp_init(77)) . '<br><br>';
echo "gmp_lcm(93, 0) = " . gmp_lcm(93, 0) . '<br><br>';
echo "gmp_lcm(0, 93) = " . gmp_lcm(0, 93) . '<br>';
?>