PHP | gmp_nextprime() Function Last Updated : 14 Apr, 2018 Comments Improve Suggest changes Like Article Like Report 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). Syntax: gmp_nextprime($num) 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. Examples: 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. php <?php // PHP program to calculate the prime number greater // than that of a GMP number passed as arguments // strings as GMP numbers $num = "135"; // gives the prime number just greater // than 135 as a GMP number $res = gmp_nextprime($num); echo $res; ?> Output: 137 Program 2: Program to calculate the prime number greater than that of a GMP number when GMP number is passed as an argument. php <?php // PHP program to calculate the prime // number greater than that of a GMP number // creating GMP numbers using gmp_init() $num = gmp_init(1000); // gives the prime number just greater // than 1000 as a GMP number $res = gmp_nextprime($num); echo $res; ?> Output: 1009 Reference: http://php.net/manual/en/function.gmp-nextprime.php Comment More infoAdvertise with us Next Article PHP | gmp_nextprime() Function A akash1295 Follow Improve Article Tags : Web Technologies PHP PHP-gmp Similar Reads PHP | gmp_neg() Function The gmp_neg() function is an in-built function in PHP which returns the negative of a GMP number (GNU Multiple Precision). Syntax : gmp_neg( $num ) Parameters : The function accepts only one mandatory parameter $num which can be either a GMP number resource in PHP 5.5 or a GMP object in PHP version 1 min read PHP | gmstrftime() Function The gmstrftime() function is an inbuilt function in PHP which is used to format a GMT/UTC time/date according to local settings. The gmstrftime() function in PHP behaves in the same way as strftime() except that the time returned by the gmstrftime() function is Greenwich Mean Time (GMT). The $format 2 min read PHP gmp_init() Function The gmp_init() function is an inbuilt function in PHP that is used to create a GMP number from different data types, including strings, integers, or other GMP objects. It's commonly used when you want to start performing arithmetic operations on large numbers without losing precision. Syntax: gmp_in 2 min read PHP | gmmktime() Function The gmmktime() function is an inbuilt function in PHP which is used to return the Unix timestamp for a GMT date. The $hour, $minute, $second, $month, $day, $year and $is_dst are sent as parameters to the gmmktime() function and it returns an integer Unix timestamp on success or False on error. Synta 2 min read PHP | gmp_or() Function The gmp_or() is an inbuilt function in PHP which is used to calculate the bitwise OR of two GMP numbers(GNU Multiple Precision : For large numbers). Syntax: gmp_or($num1, $num2) Parameters: This function accepts two GMP numbers, $num1, $num2 as mandatory parameters as shown in the above syntax. Thes 2 min read Like