function getSum(num,sum=0) { for(var i=1;i<=num;i++) { sum += i; } if(num>1) { getSum((num-1),sum); } } getSum(n);
第2个回答 2010-12-22
<?php /* * Created on 2010-12-22 * * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates */ $total=0; for($k=1;$k<=10;$k++){ for($i=0;$i<$k;$i++){