Skills101
← All coding problems

Climbing Stairs

easyDynamic Programming+10 XPTime limit 2s

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

Input: one integer n.

Output: the number of distinct ways.

Constraints: 1 ≤ n ≤ 80 (the answer fits in a 64-bit integer).

Sample input 1

2

Sample output 1

2

Sample input 2

3

Sample output 2

3

📖 Stuck? Learn the pattern

Read input from standard input and print the answer to standard output. Your code runs in a secure sandbox against the samples (Run) and hidden tests (Submit).

Loading editor…

Log in to run and submit your code — it's free.