The GATE Grind

GATE 2017 CS – Question 57

Engineering Mathematics · Discrete Mathematics: Combinatorics (Counting, Recurrence Relations, Generating Functions) · 2 marks · Numerical answer

The number of integers between 1 and 500 (both inclusive) that are divisible by 3 or 5 or 7 is ________.

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 271

Explanation

Use inclusion and exclusion. Divisible by 3: 166, by 5: 100, by 7: 71. Divisible by both 3 and 5 (15): 33, by 3 and 7 (21): 23, by 5 and 7 (35): 14. Divisible by all three (105): 4. The total is $166 + 100 + 71 - 33 - 23 - 14 + 4 = 271$.