write a php program to accept a number from the user and print it factorial code example
Example 1: php program to find factorial of a number using function
<?php
function Factorial($number){
if($number <= 1){
return 1;
}
else{
return $number * Factorial($number - 1);
}
}
$number = 5;
$fact = Factorial($number);
echo "Factorial = $fact";
?>
Example 2: php program to find factorial of a number using function
function Factorial($number){
if($number <= 1){
return 1;
}
else{
return $number * Factorial($number - 1);
}
}
$number = 5;
$fact = Factorial($number);
echo "Factorial = $fact";
?>