//echo fn(4);
echo fn2(4);
//n! = 1* 2 * 3 * ... n
function fn($n){
if($n == 0) return 1;
$fn = 1;
for($i = 1; $i <= $n ; $i++){
$fn *= $i;
}
return $fn;
}
//n! = (n-1)! * n
//0!=1 1!=1
function fn2($n){
if($n == 0 || $n == 1){
return 1;
}
$result = fn2($n-1) * $n;
return $result;
}