note 73232 modified in function.shuffle by danbrown
| From: | danbrown@php.net | Date: | Fri, 25 Jul 2008 17:49:30 +0000 |
| Subject: | note 73232 modified in function.shuffle by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142724@lists.php.net to get a copy of this message | ||
Permutation using recursion
<?php
function perm($n)
{
if($n <= 1) return 1;
else return $n * perm($n-1);
}
?>
Usage example:
<?php $result = perm(8); ?>
$result will be 40320
--was--
Permutation using recursion
function perm($n)
{
if($n <= 1) return 1;
else return $n * perm($n-1);
}
Usage example:
$result = perm(8);
$result will be 40320
http://php.net/manual/en/function.shuffle.php