标签:
function sum($n){ if($n > 1){ $tmp = sum($n -1) + $n; echo $n, ‘<br />‘; return $tmp; }else{ echo 1 , ‘<br />‘; return 1; } } echo sum(5); echo ‘<br />‘.‘=========================‘; function sum2($n){ if($n > 1){ echo $n, ‘<br />‘; return sum2($n -1) + $n; }else{ echo 1 , ‘<br />‘; return 1; } } echo sum2(5);
深入理解递归
标签:
原文地址:http://www.cnblogs.com/yusam/p/4812717.html