Question: Due on 2 0 2 4 - 0 3 - 0 7 , 2 3 : 5 9 IST Fibonacci Fibonacci is a young resident
Due on : IST
Fibonacci
Fibonacci is a young resident of the Italian city of Pisa. He spends a lot of time visiting the Leaning Tower of Pisa, one of the iconic buildings
in the city, that is situated close to his home. During all his visits to the tower, he plays a strange game while climbing the marble steps of the
tower.
The Game
Fibonacci likes to climb the steps either one at a time, two at a time, or three at a time. This adds variety to the otherwise monotonous task of
climbing. He wants to find the total number of ways in which he can climb steps, if the order of his individual steps matters. Your task is to
help Fibonacci compute this number.
For example, if he wishes to climb three steps, in the case of he could do it in four different ways:
: do it in three moves, one step at a time
: do it in two moves, first take a single step, then a double step
: do it in two moves, first take a double step, then a single step
: do it in just one move, directly leaping to the third step
To take another example, if then some of the sequences could be:
Each sequence is one of the ways of climbing five steps. The point to note here is that each element of a sequence can only be or
Write a recursive function named steps that accepts a positive integer as the argument. It should return the total number of ways in which
Fibonacci can ascend steps. Note that the order of his steps is important.
You do not have to accept input from the user or print output to the console. You just have to write the function definition.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
