note 120066 deleted from ref.math by cmb
| From: | cmb@php.net | Date: | Sun, 21 Jul 2019 09:00:33 +0000 |
| Subject: | note 120066 deleted from ref.math by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211662@lists.php.net to get a copy of this message | ||
Note Submitter: erikvandeven100 at gmail dot com
----
This is my factorial method
<?php
function factorial($nr)
{
$product = array_product(range(1,++$nr));
return $product / $nr;
}
?>
It uses the reversed method by applying division instead of multiplication, so it even returns the
right answer when entering 0.