兔子问题

public class Demo01 {
    public static void main(String args[]) {
        math mymath = new math();
        for (int i = 1; i <= 20; i++)
            System.out.println(mymath.f(i));
    }
}
class math {
    public int f(int x) {
        if (x == 1||x == 2)
            return 1;
        else
            return f(x - 1) + f(x - 2);
    }
}
最后修改:2020 年 05 月 10 日
如果觉得我的文章对你有用,请随意赞赏