PHP | gmp_fact() for large factorials Last Updated : 14 Apr, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The gmp_fact() is a built-in function in PHP which is used to calculate the factorial of a GMP number (GNU Multiple Precision : For large numbers). Syntax: gmp_fact ( $num ) Parameters: This function accepts a GMP number as a mandatory parameter as shown in the above syntax. It can be a GMP object in PHP version 5.6 and later, or a numeric string provided that it is possible to convert the latter to a number.This function calculates the factorial of this number and returns it. Return Value: This function returns a GMP number which is the factorial of the number passed as parameter. Examples: Input : "9" Output : 362880 Input : 25 Output : 15511210043330985984000000 Below programs illustrate the gmp_fact() function in PHP : Program 1: php <?php $fact = gmp_fact(5); echo gmp_strval($fact); ?> Output: 120 Program 2: php <?php $fact = gmp_fact(25); echo gmp_strval($fact); ?> Output: 15511210043330985984000000 Reference: http://php.net/manual/en/function.gmp-fact.php Comment More infoAdvertise with us Next Article PHP gmp_legendre() Function R RICHIK BHATTACHARJEE Follow Improve Article Tags : Misc Web Technologies PHP PHP-math PHP-gmp +1 More Practice Tags : Misc Similar Reads PHP | gmp_add() for adding large numbers The gmp_add() is a built-in function in PHP which is used to add two GMP numbers (GNU Multiple Precision : For large numbers). Syntax : gmp_add ( $num1, $num2 ) Parameters: This function accepts two GMP numbers as mandatory parameters as shown in the above syntax. These can be a GMP object in PHP ve 1 min read PHP | Factorial of a number In mathematics, the factorial of a number is the product of all positive integers less than or equal to that number. It is denoted by n!. The factorial of a number can be expressed mathematically as: n! = n * (n-1) * (n-2) * ........ * 1Methods to Calculate Factorials in PHPThere are several methods 3 min read PHP gmp_legendre() Function The gmp_legendre() function is an in-built function in PHP which computes the Legendre symbol of two GMP numbers (GNU Multiple Precision: For large numbers) $num1 and $num2 passed as parameters to the function and returns it. $num2 must be positive and odd. Syntax: gmp_legendre( $num1, $num2 ) Param 2 min read PHP | gmp_divexact() Function The gmp_divexact() is a built-in function in PHP which is used to check whether a GMP number(GNU Multiple Precision : For large numbers) is exactly divisible by another GMP number or not. If it so happens then function returns the exact result else any other irrelevant GMP number. Syntax: gmp_divexa 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 PHP | gmp_com() Function The gmp_com() is an inbuilt function in PHP which is used to calculate the one's complement of a GMP number(GNU Multiple Precision : For large numbers). Syntax: gmp_com($num) Parameters: This function accepts a GMP number $num as a mandatory parameter as shown in the above syntax. This parameter can 2 min read Like