Climbing Stairs
You are climbing a staircase that takes n steps to reach the top. Each move you may climb either 1 or 2 steps. Return the number of distinct ordered ways to reach the top.
Open official problem prompt ↗Count how many different ordered sequences of 1-step and 2-step moves sum to exactly n.
Hopping up stairs one or two at a time; the number of routes to a given step is just the sum of the routes to the two steps you could have jumped from.
- Input
- n = 3
- Output
- 3
- Why
- The ways are 1+1+1, 1+2, and 2+1 -- three distinct orderings.
1 <= n <= 45