标签:
以下是我对递归的理解如果有不对希望大家指正,谢谢。
附上代码:
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
int sum = DiGui(5);
System.out.println("mainSum="+sum);
}
private static int DiGui(int n) {
int sum = 0;
if(0 == n) {
return 1;
}
else {
sum = n * DiGui(n-1);
System.out.println("sum="+sum);
}
return sum;
}
}
标签:
原文地址:http://www.cnblogs.com/lwl739258698/p/5183282.html