You are climbing a staircase with `n` steps. Each time you can climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Examples
Input
n = 2
Output
2
1+1 or 2
Input
n = 3
Output
3
Constraints
- 1 <= n <= 45
You are climbing a staircase with `n` steps. Each time you can climb 1 or 2 steps. In how many distinct ways can you climb to the top?
n = 2
2
1+1 or 2
n = 3
3
Explore step-by-step interactive animations, memory state tracking, and live multi-language execution in DrawCode.
Launch Interactive Visualizer