Factorial using recursion :
Program:
<?php
function factorial($n) {
if ($n == 1) {
return 1;
} else {
return $n * factorial($n - 1);
}
}
$num = 5;
echo "The factorial of $num is: " . factorial($num);
?>
Hi there 👋
How can I help you today?