递归
作者:互联网
方法自己调用自己
递归实现数据区间的累加和
public class Test{
public static void main(String[] args){
int n = sim(1,3);
System.out.println(n);
}
}
public static int sum(int start,int end){
if(start = end){
return start;
}
return start+ sum(start+1,end);
}
标签:end,递归,int,sum,start,static,public 来源: https://www.cnblogs.com/On1on/p/16644555.html