public class Demo01 {
public static void main(String args[]) {
for (int i = 1; i <= 20; i++)
System.out.println(f(i));
}
public static int f(int x) {
if (x == 1||x == 2)
return 1;
else
return f(x - 1) + f(x - 2);
}
}
还有一种
public class fr {
public static void main(String[] args) {
demo s=new demo();
for(int i=1;i<=20;i++) {
System.out.println(s.tuzi(vb ));
}
}
}
class demo{
public int tuzi(int i) {
if(i==1||i==2) {
return 1;
}else {
return tuzi(i-1)+tuzi(i-2);
}
}
}