note 86415 deleted from ref.math by danbrown
| From: | danbrown@php.net | Date: | Fri, 28 Nov 2008 20:30:46 +0000 |
| Subject: | note 86415 deleted from ref.math by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147214@lists.php.net to get a copy of this message | ||
Note Submitter: LXS
----
In the Math library, 2 function are missed:
1.) Factorial function
2.) Combines function
1.) CODE:
<?PHP
function factorial ($n) {
if ($n == 0) { return 1; }
return $n * factorial($n - 1);
}
?>
2.) CODE:
<?PHP
function combinari ($n,$k) {
if (0 <= $k && 0 <= $n && $k <= $n) {
$combinari = factorial ($n) / (factorial ($k) * (factorial ($n - $k)));
} else {
print 'Calculul efectuat este imposibil, combinari de N luate cate K ( K mai mic sau egal
cu N )!';
}
return $combinari;
}
?>