Test Informed Learning with Examples

Logo

Repository with assignments using the Test Informed Learning with Examples (TILE) method to integrate testing into existing programming courses for free.

Menu

Fibonacci sequences

Implement a function fib(n) that returns a list with the first n numbers of Fibonacci. If n == 0, the function must return the list [1], if n == 1, the function must return the list [1,1]. When n < 1, then start with the list [1,1] and add the next Fibonacci number by adding the previous numbers in the list.

For example by typing:

>>> print(fib(0))
    [1]
>>> print(fib(1))
    [1, 1]
>>> print(fib(2))
    [1, 1, 2]
>>> print(fib(12))
    [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]

Don’t forget your pytests to automate the tests!