The Fibonacci sequence starts 0, 1 and every later number is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, 13, .... Write fib_loop(n) that returns the n-th Fibonacci number, where fib_loop(0) is 0 and fib_loop(1) is 1. Use a loop, not recursion.
Examples
Input: n = 10
Output: 55
Input: n = 0
Output: 0
Constraints
0 <= n <= 300
Goals
- Generate a number sequence where each term depends on the previous two
- Update two variables together in a loop