• PHP Video Tutorials

PHP - gmp_fact() Function



Definition and Usage

The gmp_fact() function calculates factorial of given number.

Description

gmp_fact() will return factorial of given number.

Syntax

gmp_fact ( mixed $a ) : GMP

Parameters

Sr.No Parameter & Description
1

a

It can a GMP resource number , a gmp object or a numeric string.

Return Values

PHP gmp_fact() function returns factorial as a GMP number.

PHP Version

This function will work from PHP Version greater than 5.0.0.

Example 1

Working of gmp_fact −

<?php
   $fact = gmp_fact('16');
   echo "The factorial of 16 is : ".$fact;
	
   echo "<br/><br/>";
	
   $fact1 = gmp_fact('4');
   echo "The factorial of 4 is : ".$fact1;
?>

This will produce following result −

The factorial of 16 is : 20922789888000
The factorial of 4 is : 24

Example 2

Working of gmp_fact −

<?php
   $fact = gmp_fact('45');
   echo "The factorial of 456 is : ".$fact;
?>

This will produce following result −

The factorial of 456 is : 119622220865480194561963161495657715064383733760000000000
php_function_reference.htm
Advertisements