Question: JAVA: Implement an efficient recursive fibonacci(int n) method that returns a Pair object containing the nth and (n+1)the Fibonacci numbers. That means fibonacci(0) will return
JAVA:
Implement an efficient recursive fibonacci(int n) method that returns a Pair
That means fibonacci(0) will return (0,1), fibonacci(1) will return (1,1), fibonacci(2) will return (1,2) and so on.
(Note: the pairs (0,1), (1,1) etc. are actually Pairs of Long objects , not ints .)
Your method will be called with some big values of n, so it must be efficient to avoid a timeout.
Hint: This can be implemented using four lines of code.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
