I'm trying to make a program that calculates the factorial of a number.
I did it with a while and if it worked for me but I try it with a do while but it does not give me any results
this is with while
<?php
$num=5;
$actorial=1;
$w=$num - 1;
while($w>=1){
echo $actorial ."x". $w. "=";
$actorial=$actorial * $w;
echo $w--;
}
echo $actorial;
?>
throws this:
1x4 = 44x3 = 312x2 = 224x1 = 124
with do while
<?php
$w=$num-1;
$num=5;
$actorial=1;
do{
echo $actorial ."x". $w. "=";
$actorial=$actorial * $w;
echo $w--;
echo $actorial;
}while($w>=1);
?>