← Back to Recursion
Question 613
Ways To Climb Stairs
Ways To Climb Stairs
Write climb_ways(n: int) -> int that returns how many different ways there are to climb a staircase of n stairs when each move is either 1 or 2 stairs, by recursion: a staircase of 0 or 1 stairs has exactly one way, and otherwise the count is the ways for n - 1 stairs (last move was a single step) plus the ways for n - 2 stairs (last move was a double step). The tests keep n at 20 or below. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: one integer n, no prompt, which the tests read and pass to your function before printing the value it returns.
Expected Output:
5= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Recursion
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.