Challenge 3: Return Sequence of Fibonacci Numbers

Use iterators to return a list containing the Fibonacci sequence.

Problem Statement

Edit the following iterator class to return the Fibonacci sequence from the first element up to the nth element.

The Fibonacci Sequence is the series of numbers in which the next term is found by adding the two previous terms:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...

Here , the number 0 is the first term, 1 is the second term, 1 is the third term and so on…


A number n


The range of fibonacci numbers from 0 to n

Sample Input


Sample Output

[0, 1, 1, 2, 3, 5, 8, 13]

Coding Exercise

Write your code below. It is recommended​ that you try solving the exercise yourself before viewing the solution.

Get hands-on with 1000+ tech skills courses.