public class Digui1 {
int sum=0;
int a=2;
public void sum()
{
sum+=a;
a++;
if(a<=100)
{
sum();//调用自身实现递归
}
}
public static void main(String[] args) {
Digui1 test=new Digui1();
test.sum();
System.out.println("计算结果:"+test.sum+"!");
}
}