ProgrammingHardGATE CS · Campus placements

A stair can be climbed by 1, 2 or 3 steps. How many ways are there to climb 4 stairs?

  1. A. 6
  2. B. 8
  3. C. 7
  4. D. 4

Correct answer: C. 7

Let W(n) = W(n-1) + W(n-2) + W(n-3) with W(0) = 1. Then W(1) = 1, W(2) = 2, W(3) = 4 and W(4) = 7.

More C Programming questions

Exams that ask this topic