Data Structures & AlgorithmsHardGATE CS · TCS NQT

How many integers from 1 to 100 inclusive are divisible by at least one of 3, 5 or 7?

  1. A. 56
  2. B. 55
  3. C. 47
  4. D. 46

Correct answer: B. 55

Inclusion-exclusion: 33 + 20 + 14 - 6 - 4 - 2 + 0 = 55 gives the count, while forgetting the pair-intersections overshoots. Using only 3 and 5 is a different set.

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

Exams that ask this topic