Java--斐波拉契数列

package com.company;
import java.util.Scanner;

class l{
    int n;
    int fibo(int n)
    {
        int ret;
        if(n==1 || n==2)
            return 1;
        else
            ret=fibo(n-1)+fibo(n-2);
        return ret;
    }
}

public class Main {

    public static void main(String[] args) {
        // write your code here


        int  f;
        Scanner scan=new Scanner (System.in);
        f=scan.nextInt();
        l t = new l();
        System.out.println(+t.fibo(f));



    }
}

 

posted @ 2020-12-22 00:36  zhou小月  阅读(64)  评论(0编辑  收藏  举报