package cglib;java
import java.util.Scanner;input
public class jiekou {class
public static void main(String[] args) {
// TODO Auto-generated method stub
int n=0;
@SuppressWarnings("resource")
Scanner scan=new Scanner(System.in);
System.out.println("input n:");
n=scan.nextInt();
int sum=0;
sum=plus(sum,n);
System.out.println(sum);
}
public static int plus(int sum,int n){
@SuppressWarnings("unused")
boolean is_end=true;
sum+=n;
is_end=(n>0) && ((sum=plus(sum,--n))>0);
return sum;
}
}import
輸出:
input n:
5
15sed