Function: Nth Fibonacci
mediumQuestion 117Complete the function fib so it returns the nth Fibonacci number (1-indexed, where fib(1)=0, fib(2)=1, and each later term is the sum of the previous two). The main function reads n and prints fib(n).
Example: input 7 prints 8 (sequence: 0 1 1 2 3 5 8).
Expected output
8= newline. No newline after the last line.
Hints4 available
Sign in to use hintsTopics
Functions/Methods
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.