Think in Java第四章练习题

时间:2022-04-11 11:40:21

Think in Java第四章练习题

代码如下:

package cn.thinkinjava.yys;

public class Exercise9 {
public static int num(int n) {
if(n == 1){
return 1;
}
if (n == 2) {
return 1;
}else{
return num(n - 1) + num(n - 2);
}
}
public static void main(String[] args) {
int i = Integer.parseInt(args[0]);
System.out.println("First"+i+"Fibonacci number(s):");
for (int j = 0; j <= i; j++) {
System.out.println(num(j));
}
}
}


运行一直出错
Think in Java第四章练习题