CJCoding With Joseph

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
๐Ÿ“ฅ Auto-Input:
7\n
This input is automatically fed to your program's stdin
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.