PHP | gmp_gcd() Function Last Updated : 09 Apr, 2018 Comments Improve Suggest changes Like Article Like Report The gmp_gcd() is an in built function in PHP which is used to calculate the GCD of 2 GMP numbers (GNU Multiple Precision : For large numbers). Syntax: gmp_gcd ( $num1, $num2 ) Parameters: This function accepts two GMP numbers $num1 and $num2 as parameters. This function calculates the GCD of these two numbers. Return Value: This function returns a positive GMP number which is the GCD of $num1 and $num2. Examples: Input : gmp_gcd("12", "21") Output : 3 Input : gmp_gcd("15", "30") Output : 15 Explanation: In the above example gmp_gcd() function calculates the greatest common divisor of num1 and num2. The result is always positive even if either of, or both, input operands are negative. Below programs illustrate the gmp_gcd() function in PHP. Program 1: PHP <?php $gcd = gmp_gcd("12", "21"); echo gmp_strval($gcd) . "\n"; ?> Output: 3 Program 2: PHP <?php $gcd = gmp_gcd("15", "30"); echo gmp_strval($gcd) . "\n"; ?> Output: 15 Reference: http://php.net/manual/en/function.gmp-gcd.php Comment More infoAdvertise with us Next Article PHP | gmp_gcd() Function S Shubham_Singh_29 Follow Improve Article Tags : Misc Web Technologies PHP PHP-math Practice Tags : Misc Similar Reads PHP | gmp_gcdext() function The gmp_gcdext() is an inbuilt function in PHP which calculates the GCD ( Greatest Common Divisor ) and multipliers of a given equation such that a * x + b * y = GCD(a, b), where GCD is the greatest common divisor. This function is used to solve linear Diophantine equation in two variables . Syntax: 2 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_com() Function The gmp_com() is an inbuilt function in PHP which is used to calculate the one's complement of a GMP number(GNU Multiple Precision : For large numbers). Syntax: gmp_com($num) Parameters: This function accepts a GMP number $num as a mandatory parameter as shown in the above syntax. This parameter can 2 min read PHP | gmp_cmp() Function The gmp_cmp() is an inbuilt function in PHP which is used to compare two GMP numbers(GNU Multiple Precision : For large numbers). Syntax: gmp_cmp($num1, $num2) Parameters: This function accepts two GMP numbers $num1 and $num2 as mandatory parameters as shown in the above syntax for comparing. These 2 min read PHP | gmp_xor() Function The gmp_xor() is an in-built function in PHP which is used to calculate the XOR of 2 GMP numbers (GNU Multiple Precision : For large numbers). Syntax: gmp_xor( $num1, $num2 ) Parameters: This function accepts two GMP numbers $num1 and $num2 as mandatory parameters shown in the above syntax. These pa 2 min read PHP gmp_lcm() Function 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 repre 1 min read 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_and() Function The gmp_and() is an inbuilt function in PHP which is used to calculate the bitwise AND of two GMP numbers(GNU Multiple Precision : For large numbers). Syntax: gmp_and($num1, $num2) Parameters: This function accepts two GMP numbers, $num1, $num2 as mandatory parameters as shown in the above syntax. T 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_sub() Function The gmp_sub() is an in-built function in PHP which returns the subtraction of the two GMP numbers.(GNU Multiple Precision: For large numbers) Syntax: gmp_sub($num1, $num2) Parameters: This function accepts two GMP numbers $num1 and $num2 as mandatory parameters shown in the above syntax. These param 2 min read Like