Exercise 1: Fibonacci Series
Test your understanding of generator functions by solving the Fibonacci series challenge.
We'll cover the following
Problem statement
Let’s create a generator function to produce a Fibonacci series that does not exceed the desired value.
Function description
The Fibonacci series is a sequence of numbers in which each subsequent number is the sum of two previous numbers.
In the fibonocciSeries()
function, you are required to yield
the Fibonacci numbers. The stopping criteria is the number n
given as the input of the function; the series sequence should not exceed that value.
🔖Tip: Start the counter from zero.
Sample input and output
Input | Output |
---|---|
25 | 0, 1, 1, 2, 3, 5, 8, 13, 21 |
Exercise
The solution to this exercise is available in the next lesson. However, it’ll be good practice to solve this problem on your own first. Good luck!
Get hands-on with 1400+ tech skills courses.