← Back to Functions/Methods
Question 117
Function: Nth Fibonacci
Function: Nth Fibonacci
Complete the function fib so it returns the nth Fibonacci number (1-indexed, wherefib(1)=0,fib(2)=1, and each later term is the sum of the previous two). The main function reads n and printsfib(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.