What is gmp_fact in PHP?

gmp_fact is a function in PHP that calculates the factorial of the argument passed.

Syntax

gmp_fact(GMP|int|string $num): GMP

Parameters

The function takes in one parameter, num.

num can be a numeric string, GMPGNU Multiple Precision Arithmetic Library object, or an int type value.

Return value

The function returns the factorial of num. The value returned is a GMP type number.

Code

<?php
$val1 = gmp_fact(4);
echo gmp_strval($fact1) . "\n";
?>

Expected output

24

Free Resources