Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B

What is the sum of all integers x in [1, 50] that are divisible by 4 or by 6?

  1. A. 409
  2. B. 410
  3. C. 412
  4. D. 408

Correct answer: D. 408

Use inclusion-exclusion on the sums: multiples of 4 plus multiples of 6 minus multiples of 12 (counted once).

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

Exams that ask this topic