Challenge 3: Return Sequence of Fibonacci Numbers
Use iterators to return a list containing the Fibonacci sequence.
We'll cover the following
Problem Statement
Edit the following iterator class to return the Fibonacci sequence from the first element up to the n
th 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…
Input
A number n
Output
The range of fibonacci numbers from 0 to n
Sample Input
8
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 1400+ tech skills courses.