summaryrefslogtreecommitdiff
path: root/tests/recurse
blob: 026394a9f4db33d2d5cc83e5956bb70c958e7cee (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<150; $i++) {
	$sum = $sum+factorial($i);
}
endfor;

print "\$sum=$sum\n";