ProgrammingVery hard

A program climbs a staircase of 5 steps, each move going up one or two steps. How many distinct ways are there?

  1. A. 8
  2. B. 5
  3. C. 6
  4. D. 13

Correct answer: A. 8

The counts satisfy f(n) = f(n - 1) + f(n - 2) with f(1) = 1 and f(2) = 2, giving f(5) = 8.

More C Programming questions

Exams that ask this topic