Computer >> Computer tutorials >  >> Programming >> PHP

gmp_nextprime() function in PHP


The gmp_nextprime() function computes the next prime number. This is greater than the given number.

Syntax

gmp_nextprime(val)

Parameters

  • val: The GMP number to be passed.

Return

The gmp_nextprime() function returns the prime number greater than the GMP number passed as a parameter. The returned value is itself a GMP number.

Example

The following is an example:

<?php
   $val= gmp_init(20);
   $a = gmp_nextprime($val);
   echo $a;
?>

Output

The following is the output displaying the next prime number:

23