php-src/tests/recurse
1999-12-18 17:44:56 +00:00

22 lines
231 B
Plaintext

<?
function factorial($n)
{
if ($n==0 || $n==1) {
return 1;
} else {
return $n*factorial($n-1);
}
}
for ($k=0; $k<10; $k++):
for ($i=0,$sum=0; $i<50; $i++) {
$sum = $sum+factorial($i);
}
endfor;
print "\$sum=$sum\n";