Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 4 students

Recursive Fibonacci Method

< Prev
Next >

Consider the following program. What value is printed when it is executed?

public class Fibonacci {
    public static int fib(int n) {
        if(n <= 1)
            return n;
        return fib(n - 1) + fib(n - 2);
    }
    public static void main(String[] args) {
        System.out.println(fib(4));
    }
}
A

2

B

3

C

5

D

8

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1richa.tuli22 2m 02s 78
#2singhris00011 0m 29s 71
#3ethan13 0m 41s 39
#4lightingstrikes134201 0m 00s -10
#5suhanakochhar00601 1m 35s -105
Items per page:
10
1 – 5 of 5
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|FAQ