The gmp_rootrem()
function in PHP is used to find the root of a given number.
gmp_rootrem(GMP|int|string $num, int $nth): array
num
: This is a GMP object, integer, or a string whose nth root has to be calculated.nth
: This is the positive root.This method returns an array of two elements:
The first element refers to the integer component of the root.
The second element refers to the remainder of the root.
<?php$nthroot1 = gmp_rootrem(64,2);$nthroot2 = gmp_rootrem(64,5);print_r("The square root of 64 is:\n\n");print_r($nthroot1);echo "-----------------------------------\n";print_r("The fifth root of 64 is:\n\n");print_r($nthroot2);?>
Line 2: We declare and initialize the variable $nthroot1
to store the result of the root (also known as the square root) of 64.
Line 3: We declare and initialize the variable $nthroot2
to store the result of the root of 64.
Line 6: We print the array stored in $nthroot1
.
Line 9: We print the array stored in $nthroot2
.
Free Resources