class Test { public static void main(String[] args) { // feibo j=new feibo(); for (int n = 1; n < 20; n++) { System.out.println(j.hh(n)); } } } class feibo { static int hh(int n) { if (n == 2||n==1) { return 1; } else { return hh(n - 2) + hh(n - 1); } } }
运行结果:
原文:https://www.cnblogs.com/hetaoyuan/p/10576902.html