summaryrefslogtreecommitdiff
path: root/tests/recurse
blob: 5b8c646f6b7335b10be2c3f6b5075c18c416dfc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?

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";