function Factorial($n) {
return ($n <= 1) ? 1 : $n * Factorial($n - 1);
}
function Factorial($number){
if($number <= 1){
return 1;
}
else{
return $number * Factorial($number - 1);
}
}
$number = 5;
$fact = Factorial($number);
echo "Factorial = $fact"; //output : 120
?>
<?php
// PHP program to find factorial
// of given number
// function to find factorial
// of given number
function factorial($n)
{
if ($n == 0)
return 1;
return $n * factorial($n - 1);
}
// Driver Code
$num = 5;
echo "Factorial of ", $num, " is ", factorial($num);
// This code is contributed by m_kit
?>
<?php
$no= 7;
$fact= 1;
$a=$no;
for($a=$no; $a>=1; $a--)
{
$fact= $fact* $a;
}
$msg="Factorial of $no is $fact";
?>
<p style="color:#66CC00;font-size:40px;font-family:Mistral;">
<?Php if(isset($msg))
{
echo $msg;
} ?>
</p>