The gmp_nextprime() is an inbuilt function in PHP which is used to calculate the prime number just greater than a given GMP number(GNU Multiple Precision : For large numbers).
Parameters: This function accepts a GMP number $num as a mandatory parameter as shown in the above syntax whose next prime we want to find. This parameter can be a GMP object in PHP version 5.6 and later, or we are also allowed to pass a numeric string provided that it is possible to convert that string to a number.
Return Value: This function returns a GMP number which is the prime number just greater than the GMP number passed to it as a parameter.
Input : gmp_nextprime("15") Output : 17 Input : gmp_nextprime("21") Output : 23
Below programs illustrate the gmp_nextprime() function in PHP :
Program 1: Program to calculate the prime number just greater than a GMP number when numeric string as GMP number is passed as an argument.
Program 2: Program to calculate the prime number greater than that of a GMP number when GMP number is passed as an argument.