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

gmp_nextprime

Description

The gmp_nextprime of GMP for PHP finds the next prime number.

Syntax

gmp_nextprime(
    GMP|int|string $num
): GMP

Parameters

num

A GMP object, an int or a numeric string.

Return

Returns the next prime number greater than num, as a GMP number.

Examples

1 · num · GMP

<?

$num = 7;

$num = gmp_init($num);

$return = gmp_nextprime($num);

var_dump($return);

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

2 · num · int

<?

$num = 7;

$return = gmp_nextprime($num);

var_dump($return);

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

3 · num · string

<?

$num = "7";

$return = gmp_nextprime($num);

var_dump($return);

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