Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

How many integers from 1 to 50 inclusive have a digit sum that is divisible by 5?

  1. A. 11
  2. B. 6
  3. C. 4
  4. D. 10

Correct answer: D. 10

Digit sums up to 50 are at most 13, so only sums 5 and 10 count: 5, 14, 23, 32, 41, 50 and 19, 28, 37, 46 = 10. Starting the range at 0 (digit sum 0) gives 11, counting only sum 5 gives 6 and only sum 10 gives 4.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic