You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
189 B
PHTML
16 lines
189 B
PHTML
5 years ago
|
<?php
|
||
|
|
||
|
$num = 4;
|
||
|
$factorial = 1;
|
||
|
for ($x=$num; $x>=1; $x--)
|
||
|
{
|
||
|
$factorial = $factorial * $x;
|
||
|
}
|
||
|
echo "Factorial of $num is $factorial";
|
||
|
|
||
|
?>
|
||
|
|
||
|
/*
|
||
|
Output
|
||
|
|
||
|
Factorial of 4 is 24
|