The Fibonacci Sequence
The Fibonacci sequence appears in nature all around us, in the arrangement of seeds in a sunflower and the spiral of a nautilus for example.
The Fibonacci sequence begins with and as its first and second terms. After these first two elements, each subsequent element is equal to the sum of the previous two elements.
Given , return the number in the sequence.
The Fibonacci sequence to is . With zero-based indexing, .
Complete the recursive function in the editor below.
fibonacci has the following parameter(s):
- int: the element in the Fibonacci sequence
The integer .
3 n = 3
The Fibonacci sequence begins as follows:
In the sequence above, is .