โ 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, 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
Topics:
Functions/Methods
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.