Climbing Stairs
Easyjavapythonccppjavascript
You are climbing a staircase with N steps. Each move you can climb either 1 or 2 steps. Count the number of distinct ways to reach the top.
Input Format
A single line containing the integer N.
Output Format
Print the number of distinct ways.
Example 1
Input
5
Output
8
Explanation: There are eight different sequences of 1-step and 2-step moves.
- 1 <= N <= 45
Submit an attempt to unlock the solution. (Sign in first.)
Related Problems
- House RobberMedium · java, python, c, cpp, javascriptSolve Problem
- 0/1 KnapsackMedium · java, python, c, cpp, javascriptSolve Problem
- Longest Common SubsequenceMedium · java, python, c, cpp, javascriptSolve Problem