programming-examples/php/_Basics/Factorial of a number in PHP.php

16 lines
189 B
PHP
Raw Normal View History

2019-11-15 12:59:38 +01:00
<?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