note 95571 deleted from function.gmp-mul by danbrown
| From: | danbrown@php.net | Date: | Sun, 10 Jan 2010 03:43:09 +0000 |
| Subject: | note 95571 deleted from function.gmp-mul by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164823@lists.php.net to get a copy of this message | ||
Note Submitter: Nitrogen
----
The code in the comment below is wrong.
The for(); loop should test if $i<=$x; not $i<$x..
<?php
function Factorial($Input=1) {
$Result=1;
for($i=2;$i<=$Input;$i++)
$Result=gmp_mul($Result,$i);
return($Result);
}
// Factorial(5); would return a GMP resource with '120'.
?>