16Fibonacci Number

    Easyloopsmath

    The Fibonacci sequence starts 0, 1 and each next number is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, 13, …

    Write fib(n) that returns the number at position n, counting from 0. So fib(0) is 0 and fib(6) is 8.

    Examples

    Example 1
    >>> fib(6)
    8
    Example 2
    >>> fib(0)
    0

    Run examples checks the 2 examples above. Submit runs all 6 tests, including hidden edge cases, and marks the challenge solved.

    solution.py
    Loading Python…

    Test results show up here

    Write fib in the editor, then run the examples. Use print() freely: its output is shown for each test.