Problem Statement:
Suppose there is a staircase that you can climb in either 1 step, 2 steps, or 3 steps. In how many possible ways can you climb the staircase if the staircase has n steps? Write a recursive function to solve the problem.
Example:
n = 3
Output = 4
The output is 4 because there are four ways we can climb the staircase:
1. 1 step + 1 step + 1 step
2. 1 step + 2 steps
3. 2 steps + 1 step
4. 3 steps
Find the solution Here
Note: try to solve it with recursion.
Follow Programmers Door for more.
Comentarios