205k views
5 votes
Fill in the code to complete the following function for computing a Fibonacci number. public static int fib(int index)

User Twinsen
by
5.0k points

1 Answer

5 votes

Answer:

return 0;

Explanation:

The Fibonacci numbers such that each number is the sum of the two preceding ones, but the first therm of the sequence cannot be built by this rule.

In that
F_(0) = 0

Then you may define it in the base case

return 0;

User Batuman
by
5.5k points