note 101726 added to function.gmp-fact
| From: | jbboehr at gmail dot com | Date: | Fri, 07 Jan 2011 09:00:20 +0000 |
| Subject: | note 101726 added to function.gmp-fact | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175509@lists.php.net to get a copy of this message | ||
Here's a short, lazy version of ghsot's function (with support for "division" of
factorials), and a function that calculates number of permutations:
<?php
function factorial($n, $b = 1) {
$v = 1;
do { $v *= $n; } while( --$n > $b );
return $v;
}
function permutations($n, $k = 2)
{
if( $n < $k ) return false;
return factorial($n, $n - $k);
}
----
Server IP: 69.147.83.197
Probable Submitter: 99.167.93.41
----
Manual Page -- http://www.php.net/manual/en/function.gmp-fact.php
Edit -- https://master.php.net/note/edit/101726
Del: integrated -- https://master.php.net/note/delete/101726/integrated
Del: useless -- https://master.php.net/note/delete/101726/useless
Del: bad code -- https://master.php.net/note/delete/101726/bad+code
Del: spam -- https://master.php.net/note/delete/101726/spam
Del: non-english -- https://master.php.net/note/delete/101726/non-english
Del: in docs -- https://master.php.net/note/delete/101726/in+docs
Del: other reasons-- https://master.php.net/note/delete/101726
Reject -- https://master.php.net/note/reject/101726
Search -- https://master.php.net/manage/user-notes.php