php使用递归函数实现数字累加,下面是一个简单的范例
<? function summation ($count) { if ($count != 0) : return $count + summation($count-1); endif; } $sum = summation(10); print "Summation = $sum"; ?>
php使用递归函数实现数字累加,下面是一个简单的范例
<? function summation ($count) { if ($count != 0) : return $count + summation($count-1); endif; } $sum = summation(10); print "Summation = $sum"; ?>