The Fibonacci numbers start F(0) = 0, F(1) = 1, and every next number is the sum of the previous two. Return F(n).
The starter code follows the definition directly. It is correct but takes far too long once n reaches 40 or so. Make it fast.
Example 1
Input:
nth_fibonacci(10)
Output:
55
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55.
Example 2
Input:
nth_fibonacci(0)
Output:
0
0 <= n <= 50000No results yet
Run your code to check it against the examples, or submit to run every test.