![]() |
VOOZH | about |
The gmp_root() is an in-built function in PHP which returns the integer part of the N-th root of a GMP number(GNU Multiple Precision: For large numbers).
Syntax:
gmp_root( $num, $n )
Parameters: The function accepts two mandatory parameters $num and $n.
Return Value: This function returns a positive GMP number which is the integer part of the N-th root of the $num.
Examples:
Input : $num = "20" $n = 2 Output : 4 Input : $num = "9" $n = 2 Output : 2
Below programs illustrate the gmp_root() function:
Program 1: The program below demonstrates the working of gmp_root() function when GMP number is passed as argument..
Output:
10
Program 2: The program below demonstrates the working of gmp_root() when numeric string is passed as an argument.
Output:
2
Program 3: Program to find the integer part of a square root of a number.
Output:
5
Reference:
https://www.php.net/manual/en/function.gmp-root.php