PHP gmp_lcm() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes 1 Likes 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 Create Quiz Comment N neeraj3304 Follow 1 Improve N neeraj3304 Follow 1 Improve Article Tags : PHP PHP-function PHP-gmp Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like