Data Structures & AlgorithmsModerateCAT · TCS NQT

Problem: How many numbers from 1 to 1000 have a digit sum divisible by 9?

  1. A. 55
  2. B. 112
  3. C. 111
  4. D. 333

Correct answer: C. 111

Digit sum ≡ x (mod 9), so this counts multiples of 9 in 1..1000: 111. Requiring digit sum exactly 9 gives 55, adding 0 gives 112, and 333 counts digit sums divisible by 3.

More Coding Interview Problems questions

Exams that ask this topic