PIXELBANKv9.1.0
Menu

You are climbing a staircase with n steps. Each time you can climb 1 or 2 steps. How many distinct ways can you reach the top?

Example:

Input:
3
Output:
3
Reasoning:
  • To reach the top of a staircase with 3 steps, we can climb 1 or 2 steps at a time, so we consider all possible combinations of 1 and 2 steps.
  • The distinct ways to reach the top are:
    • 1 step + 1 step + 1 step
    • 1 step + 2 steps
    • 2 steps + 1 step
  • We count the number of distinct ways, which is 33 in this case.
  • The final output is the total count of distinct ways, which is 3\boxed{3}.

Constraints:

  • 1 <= n <= 45
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.