Write a php program to print factorial of a number:
Answer:
$num = 7;
$factorial = 1;
for ($x=$num; $x>=1; $x--)
{
$factorial = $factorial * $x;
}
echo "Factorial of $num is $factorial";
?>
Output:
Factorial of 7 is 5040
Answer:
$num = 7;
$factorial = 1;
for ($x=$num; $x>=1; $x--)
{
$factorial = $factorial * $x;
}
echo "Factorial of $num is $factorial";
?>
Output:
Factorial of 7 is 5040
No comments:
Post a Comment