<?php
GMP gmp_powm ( GMP|int|string $num,
GMP|int|string $exponent,
GMP|int|string $modulus )
where,
$num = The GMP number base
$exponent = The GMP number to raise the base
$modulus = The GMP number as modulo
?>
<?php
// A new result is shown if you run
// this exercise several times
$a01a = [ 0, '0x100', 256, '0400' ];
$a01b = mt_rand(0, 3);
$m01c = PHP_INT_MAX;
foreach($a01a as $n01a)
{
$pm01ab = gmp_powm($n01a, $a01b, $m01c);
echo 'gmp_powm( ' . $n01a . ', ' . $a01b . ', ' .
$m01c .' ) = ' . $pm01ab . '<br>';
}
?>
<?php
var_dump(gmp_strval(gmp_powm(0,1,10)));
echo "<br><br>";
var_dump(gmp_strval(gmp_powm(5,1,10)));
echo "<br><br>";
var_dump(gmp_strval(gmp_powm(-5,1,-10)));
echo "<br><br>";
var_dump(gmp_strval(gmp_powm(-5,1,10)));
echo "<br><br>";
var_dump(gmp_strval(gmp_powm(-5,11,10)));
echo "<br><br>";
var_dump(gmp_strval(gmp_powm("77",3,1000)));
echo "<br><br>";
$n = gmp_init(11);
var_dump(gmp_strval(gmp_powm($n,3,1000)));
echo "<br><br>";
$e = gmp_init(7);
var_dump(gmp_strval(gmp_powm($n,$e,1000)));
echo "<br><br>";
$m = gmp_init(900);
var_dump(gmp_strval(gmp_powm($n,$e,$m)));
echo "<br><br>";
try {
var_dump(gmp_powm(5, 11, 0));
} catch (\DivisionByZeroError $error) {
echo $error->getMessage() . "<br><br>";
}
try {
var_dump(gmp_powm(5, "11", gmp_init(0)));
} catch (\DivisionByZeroError $error) {
echo $error->getMessage() . "<br><br>";
}
try {
var_dump(gmp_powm(array(),$e,$m));
} catch (\TypeError $error) {
echo $error->getMessage() . "<br><br>";
}
try {
var_dump(gmp_powm($n,array(),$m));
} catch (\TypeError $error) {
echo $error->getMessage() . "<br><br>";
}
try {
var_dump(gmp_powm($n,$error,array()));
} catch (\TypeError $error) {
echo $error->getMessage() . "<br><br>";
}
try {
var_dump(gmp_powm(array(),array(),array()));
} catch (\TypeError $error) {
echo $error->getMessage() . "<br><br>";
}
try {
$n = gmp_init("-5");
var_dump(gmp_powm(10, $n, 10));
} catch (\ValueError $error) {
echo $error->getMessage() . "<br><br>";
}
$n = gmp_init("0");
var_dump(gmp_powm(10, $n, 10));
?>
<?php
// A new result is shown if you run
// this exercise several times
$a03a = [ 0, '0x100', 256, '0400' ];
$a03b = mt_rand(-3, 0);
$m03c = PHP_INT_MAX;
foreach($a03a as $n03a)
{
$pm03ab = gmp_powm($n03a, $a03b, $m03c);
echo 'gmp_powm( ' . $n03a . ', ' . $a03b . ', ' .
$m03c .' ) = ' . $pm03ab . '<br>';
}
?>