PHP gmp_lcm() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The gmp_lcm() is an inbuilt function in PHP that is used to calculate the least common multiple (LCM) of two or more integers. Syntax: gmp_lcm(GMP|int|string $num1, GMP|int|string $num2): GMPParameters: This function accepts two parameters that are described below. $num1: A GMP number resource representing the first integer.$num2: A GMP number resource representing the second integer.Return Values: The gmp_lcm() function returns the lcm of two integers which is provided by the user. Program 1: The following program demonstrates gmp_lcm() function. PHP <?php // Assuming you have the GMP // extension enabled $a = gmp_init(12); $b = gmp_init(18); $lcm = gmp_lcm($a, $b); echo "LCM of $a and $b is: $lcm\n"; ?> Output: LCM of 12 and 18 is: 36Program 2: The following program demonstrates gmp_lcm() function. PHP <?php // Assuming you have the GMP // extension enabled $a = gmp_init(12); $b = gmp_init(18); $c = gmp_init(24); $lcm_of_three = gmp_lcm($a, gmp_lcm($b, $c)); echo "LCM of $a, $b, and $c is: $lcm_of_three\n"; ?> Output: LCM of 12, 18, and 24 is: 72Reference: https://www.php.net/manual/en/function.gmp-lcm.php Comment More infoAdvertise with us Next Article PHP gmp_lcm() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-gmp Similar Reads PHP | gmp_mul() Function The gmp_mul() function in PHP is an inbuilt function which is used to multiply two GMP numbers (GNU Multiple Precision: For large numbers). Syntax: GMP gmp_mul ( GMP $num1, GMP $num2 ) Parameters: This function accepts two GMP numbers. It is mandatory parameters as shown in the above syntax. These c 1 min read PHP | gmp_or() Function The gmp_or() is an inbuilt function in PHP which is used to calculate the bitwise OR of two GMP numbers(GNU Multiple Precision : For large numbers). Syntax: gmp_or($num1, $num2) Parameters: This function accepts two GMP numbers, $num1, $num2 as mandatory parameters as shown in the above syntax. Thes 2 min read PHP | gmp_neg() Function The gmp_neg() function is an in-built function in PHP which returns the negative of a GMP number (GNU Multiple Precision). Syntax : gmp_neg( $num ) Parameters : The function accepts only one mandatory parameter $num which can be either a GMP number resource in PHP 5.5 or a GMP object in PHP version 1 min read PHP | gmp_intval() Function The gmp_intval() is an inbuilt function in PHP which converts a GMP number to an integer. Here GMP refers to GNU Multiple Precision which is for large numbers.Syntax:Â Â int gmp_intval ( $num ) Parameters: The function accepts a single parameter $num which is a GMP number and returns its integer valu 2 min read PHP | gmp_jacobi() Function The gmp_jacobi() function is an in-built function in PHP which computes the Jacobi symbol of two GMP numbers (GNU Multiple Precision : For large numbers) $num1 and $num2 passed as parameters to the function and returns it. $num2 must be positive and odd. Syntax : gmp_jacobi($num1, $num2) Parameters 2 min read Like