1、找规律,f(n)=f(n-1)+f(n-2)
2、递归
输入:
1
2
3
4
5
9
复制
输出:
1
1
2
3
5
34


import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            int n=sc.nextInt();
            System.out.println(test(n));
            
        }
    }
    public static int test(int n){
        int count=0;
        if(n==1 || n==2 ){
                count=1;
          }else{
                count=test(n-1)+test(n-2);
            }
        return count;
    }
}