Javatpoint Logo
Javatpoint Logo

PHP gmp_gcd() Function

PHP language uses the gmp_gcd() mathematical function to figure out the greatest common divisor of a GMP parameter. This function displays the GCD value in a single line.

Syntax

The given syntax shows the required data for PHP gmp_gcd() function.

Parameters

  • As shown in the above syntax, this function requires two GMP number as a required parameter.
  • It can be a GMP object or numbers to get the largest or greatest common divisor into two parameters.

Return Values

This function gives back a GMP number as an output that is the largest common divisor of the parameter.

Examples

The given examples show the greatest common divisor of the different types of GMP parameters.

Example1: the given example shows a GCD operation with given GMP parameters. Here, we can use the numerical number to find the largest common divisor number.

Output:

The following output image shows gmp_gcd() functions value.

PHP gmp_gcd() Function

Example2: the given example shows a GCD operation with given GMP parameters. Here, we can use the negative number to find the largest common divisor number. The negative number displays the same greatest common divisor as a positive number.

Output:

The given output image shows gmp_gcd() functions value.

PHP gmp_gcd() Function

Example3: the given example shows a GCD operation with given GMP parameters. Here, we can use the numerical variable to find the greatest common divisor.

Output:

The following output image shows gmp_gcd() functions value.

PHP gmp_gcd() Function

Example4: the given example shows the greatest common divisor operation with given GMP parameters. Here, we can use the non-divisible GMP input numbers.

Output:

The following output image shows gmp_gcd() functions value. the output shows the "1" value for the non-divisor number.

PHP gmp_gcd() Function

Example5: the given example shows the greatest common divisor operation with given GMP parameters. Here, we can use other GMP function with the input numbers. The example uses add function with variable values and uses in the GCD function./p>

Output:

The given output image shows gmp_gcd() functions value.

PHP gmp_gcd() Function

Conclusion

The gmp_gcd() function uses mathematical operations to get the greatest common divisor. This function helps to reduce code size using a single function and gets output easily.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA