function factorial($n) {
if ($n <= 0) return 1;
return $n * factorial ($n-1);
}
print factorial(0)."
\n";
print factorial(1)."
\n";
print factorial(2)."
\n";
print factorial(3)."
\n";
print factorial(4)."
\n";
print factorial(5)."
\n";
print factorial(6)."
\n";
print factorial(7)."
\n";
?>
$n = 5; // установите значение n здесь
$factorial = 1;
for($i = 1; $i <= $n; $i++){
$factorial *= $i;
}
echo "Факториал числа $n равен $factorial";
?>