Data Structures & AlgorithmsVery hardGATE CS

How many integers n with 1 <= n <= 100000 are divisible by exactly one of the numbers 6, 10 and 15?

  1. A. 33332
  2. B. 26666
  3. C. 23333
  4. D. 20000

Correct answer: C. 23333

Multiples up to 100000: 16666 of 6, 10000 of 10, 6666 of 15; every pairwise lcm is 30, so each multiple of 30 (3333 of them) lies in all three sets and none lies in exactly two. Exactly one set: 33332 - 3*3333 = 23333; the union is 26666, and plain addition of the three counts gives 33332.

More Coding Interview Problems questions

Exams that ask this topic