Skip to content
Mad4Study

Engineering & Science

GATE Computer Science

  • GATE CS
  • 2026–27 pattern practice
  • Algorithms
  • Dynamic programming
  • Easy

In how many distinct ways can you climb a staircase of 10 steps if each move climbs either 1 or 2 steps?

Algorithm Design

Pick an option to check your answer.

Let W(n)W(n) be the number of ways. The last move is either 1 step or 2 steps, so W(n)=W(n−1)+W(n−2)W(n) = W(n-1) + W(n-2) with W(1)=1W(1) = 1 and W(2)=2W(2) = 2. This is the Fibonacci sequence: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, giving W(10)=89W(10) = 89.

Why not the others

  • 5555 is W(9)W(9), one step short.
  • 144144 is W(11)W(11), one step too many.
  • 2020 counts only the moves, not the ways to order them.

Report an error

GATE CS · Algorithms · Algorithm Design