PHP program to calculate the factorial of a given number using recursion
<?php
//PHP program to calculate the factorial
//of a given number using recursion.
function fact($num)
{
if ($num == 1) return 1;
return $num * fact($num - 1);
}
$result = fact(5);
echo "Factorial is: " . $result;
?>
Output
Factorial is: 120
