factoriel en php code example
Example 1: php factorial
function Factorial($n) {
return ($n <= 1) ? 1 : $n * Factorial($n - 1);
}
Example 2: factorial function php
function Factorial($number){
if($number <= 1){
return 1;
}
else{
return $number * Factorial($number - 1);
}
}
$number = 5;
$fact = Factorial($number);
echo "Factorial = $fact"; //output : 120
?>