Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

gmp_powm

Description

The gmp_powm of GMP for PHP raises a number to a power with modulo.

Syntax

gmp_powm(
    GMP|int|string $num,
    GMP|int|string $exponent,
    GMP|int|string $modulus
): GMP

Parameters

num

The base number.

A GMP object, an int or a numeric string.

exponent

The positive power to raise the num.

A GMP object, an int or a numeric string.

modulus

The modulo.

A GMP object, an int or a numeric string.

Return

Returns the new (raised) number, as a GMP number.

Examples

1 · num exponent modulus · GMP

<?

$num = 2;
$exponent = 3;
$modulus = 5;

$num = gmp_init($num);
$exponent = gmp_init($exponent);
$modulus = gmp_init($modulus);

$return = gmp_powm($num, $exponent, $modulus);

var_dump($return);

?>
object(GMP)#4 (1) {
  ["num"]=>
  string(1) "3"
}

2 · num exponent modulus · int

<?

$num = 2;
$exponent = 3;
$modulus = 5;

$return = gmp_powm($num, $exponent, $modulus);

var_dump($return);

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "3"
}

3 · num exponent modulus · string

<?

$num = "2";
$exponent = "3";
$modulus = "5";

$return = gmp_powm($num, $exponent, $modulus);

var_dump($return);

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "3"
}
HomeMenu