程序代码:
public class Test {
public static void main(String args[]) {
int x1 = 1;
int sum = 0;
int n = 7;
for (int i = 1; i <= n; i++) {
x1 = func(i);
sum = sum + x1;
}
System.out.println("sum=" + sum);
}
public static int func(int x) {
if (x > 2)
return (func(x - 1) + func(x - 2));
else
return 1;
}
}
这个题的答案是0
你看看这个程序可不可以
public static int getCount(){
int i = 1;
int j = 1;
int sum=0;
while(i<200 || j<200){
int k = i+j;
if(k>100 && k<200 && k%2!=0){
sum+=k;
}
System.out.println("i="+i);
System.out.println("j="+j);
System.out.println("k="+k);
System.out.println("**********************");
i=j;
j=k;
}
return sum;
}