الرجوع
تسجيل الدخول

The Fibonacci sequence is defined recursively as F(n) = F(n-1) + F(n-2) with initial conditions F(0) = 0 and F(1) = 1. Implement this sequence in Java by completing the fibonacci method below, where fibonacci(n) should return the nth Fibonacci number, Which of the following sets of replacements for XXX, YYY, and ZZZrespectively will complete the function?

    static int fibonacci(int n) {
        if (n <= XXX) {
            return n;
        } else {
            return YYY + ZZZ;
        }
    }