用递归实现斐波那契数列
方法/步骤
1
import java.util.Scanner;/** * 递归 */public class homework_demo01 { public static int result(int n){ if(n==1 || n==2){ return 1; } return result(n-1)+result(n-2); } public static
2
控制台输入:20Input Number:20
3
输出结果:1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181