Practice · 2 of 5
Count the ways up the stairs
CHALLENGE
Difficulty: intermediate+25 XP
You climb a staircase of n steps, taking **1 or 2 steps** at a time. Write a recursive method counting the distinct ways to exactly reach the top: process(int n) with bases ways(0) = 1 and ways(1) = 1 (the answer is Fibonacci-shaped).
Example: n = 5 → 8.
Press Submit to check your solution.
Back to lesson: Practice: Recursion gauntlet