不使用递归求1~N的和
public class RecursionTest02{
public static void main(String[] args){
int n=50;
int reValue = sum(n);
System.out.println("reValue = " + reValue);
}
//单独的定义一个方法,这是一个独立的功能,可以完成1~N的和
public static int sum(int n){
int result = 0;
for(int i = 1;i
result += i;
}
return result;
}
}



