public static void main(String[] args) {
int total = 0; //总和
total = sum(5,10);
System.out.println(total);
}
//递归实现a+ (a+1) + (a+2) +...+ b //其中a、b均为不小于1的整数,且b为所有加数的最大值
public static int sum(int a, int b){
System.out.println(b);
if(a==b){
return a; //出口
}else{
return b + sum(a, b-1);
}
}