What is the gmp_nextprime() function in PHP?
The gmp_nextprime() function in PHP is used to return the next prime number, which is greater than the argument passed.
Syntax
gmp_nextprime(GMP|int|string $num): GMP
Parameters
The function takes in one parameter, num.
numcan be a numeric string,GMPobject, or of typeint.
Return value
The function returns the next prime number which is a greater num. The value returned is type
Code
<?php$primeNum1 = gmp_nextprime(12);$primeNum2 = gmp_nextprime(16);echo gmp_strval($primeNum1) . "\n";echo gmp_strval($primeNum2) . "\n";?>
Output
13
17