<?php
GMP gmp_root ( GMP|int|string $num, int $nth )
where,
$num = The GMP numeric value
$nth = The root to consider as an INTEGER value
?>
<?php
function givegmproot01 ( $a01, $r01 )
{
echo $a01 . ' is ' . gmp_root($a01 , $r01) . '<br>';
}
$a01a = [ '0200000', '0200001',
'0x10000', '0x1000A',
65536, 65537, 7, '0xff' ];
$rnd01 = mt_rand (1, 5);
$t01 = [ 1 => 'st', 2 => 'nd', 3 => 'rd', 4 => 'th', 5 => 'th' ];
foreach($a01a as $a01)
{
echo 'The '. $rnd01.$t01[$rnd01] . ' root of ';
givegmproot01($a01, $rnd01);
}
?>
<?php
function givegmproot02 ( $a02, $r02 )
{
echo $a02 . ' is ' . gmp_root($a02 , $r02) . '<br>';
}
$a02a = [ 0, 1, 2, 3, 4 ];
$rnd02 = mt_rand (1, 5);
$t02 = [ 1 => 'st', 2 => 'nd', 3 => 'rd', 4 => 'th', 5 => 'th' ];
foreach($a02a as $a02)
{
echo 'The '. $rnd02.$t02[$rnd02] . ' root of ';
givegmproot02($a02, $rnd02);
}
?>
<?php
function givegmproot03 ( $a03, $r03 )
{
echo $a03 . ' is ' . gmp_root($a03 , $r03) . '<br>';
}
$a03a = [ 1, 2, 3 ];
$nth03 = -1;
// Attention to this value
$t03 = [ 1 => 'st', 2 => 'nd', 3 => 'rd', 4 => 'th', 5 => 'th' ];
foreach($a03a as $a03)
{
echo 'The '. $nth03.$t03[$nth03] . ' root of ';
givegmproot03($a03, $nth03);
}
?>