ProgrammingVery hardGATE CS · Campus placements

How many ordered ways are there to write 10 as a sum of parts equal to 1, 3 or 4, where the order of the parts matters?

  1. A. 64
  2. B. 55
  3. C. 49
  4. D. 81

Correct answer: A. 64

Let f(n) = f(n-1) + f(n-3) + f(n-4) with f(0) = 1. The values run 1, 1, 1, 2, 4, 6, 9, 15, 25, 40, 64, so f(10) = 64.

More C Programming questions

Exams that ask this topic