Data Structures & AlgorithmsHardCAT · TCS NQT Digital

Problem: Count the integers from 1 to 999 whose decimal digit sum is divisible by 7.

  1. A. 140
  2. B. 36
  3. C. 139
  4. D. 142

Correct answer: C. 139

Digit sums divisible by 7 are 7, 14, 21 (max 27): 36 + 75 + 28 = 139 numbers in 1..999. Including 0 gives 140, counting only digit sum exactly 7 gives 36, and counting multiples of 7 instead gives 142.

More Coding Interview Problems questions

Exams that ask this topic