Hello,
Came across this piece of code for a Factorial “formula” and can’t seem to get it:
[php]
Factorial Test
<?php
$var = rand % 10;
$counter = $var;
$echo_var = $var;
while ($counter > 1) {
$var = $var * ($counter - 1);
$counter--;
}
echo "The Factorial of $echo_var is: $var";
?>
</body>
[/php]
Could an expert kindly explain how the code works (step by step, if possible).
Thanks in advance.
Chris