• PHP Video Tutorials

PHP - gmp_lcm() Function



Definition and Usage

The gmp_lcm() function calculates LCM of the given GMP numbers.

Description

The gmp_lcm() function will return the least common multiplier for the given two GMP numbers.

Syntax

gmp_lcm ( mixed $a , mixed $b ) : GMP

Parameters

Sr.No Parameter & Description
1

a

It can a GMP resource number , a gmp object or a numeric string.

2

b

It can a GMP resource number , a gmp object or a numeric string. The value of b has to be positive and odd.

Return Values

PHP gmp_lcm() function calculates LCM and returns it as a GMP number.

PHP Version

This function will work from PHP Version greater than 7.3.0.

Example 1

Working of gmp_lcm −

<?php
   $lcm = gmp_lcm("12", "18");	
   echo "The LCM is : ".$lcm;
?>

This will produce following result −

The LCM is : 36

Example 2

Working of gmp_lcm −

<?php
   $lcm = gmp_lcm("120", "180");	
   echo "The LCM is : ".$lcm;
?>

This will produce following result −

The LCM is : 360
php_function_reference.htm
Advertisements