public class Test {
public static void main(String[] args) {
int f = Test.f(100);
System.out.println("f = " + f);
}
public static int f(int n) {
int t = 0;
boolean b = (n > 0) && ((t = f(n - 1)) >0);
return n + t;
}
}
C的写法
int func(int n)
{
int i=1;
(n>1)&&(i=func(n-1)+n);
return i;
}