How many numbers less than 1000 are NOT divisible by either: a) 2 or 5 b) 2, 5 or 7

Check the final answer first, then review the worked steps.

Answer

a) 400, b) 343

Work

a) $999 - (\lfloor\frac{999}{2}\rfloor + \lfloor\frac{999}{5}\rfloor - \lfloor\frac{999}{10}\rfloor) = 999 - (499 + 199 - 99) = 400$
b) $999 - (499 + 199 + 142 - 99 - 71 - 28 + 14) = 999 - 656 = 343$

Step-by-step solution

  1. For part (a), use the Principle of Inclusion-Exclusion. The total numbers are $999$. Divisible by $2$: $\lfloor 999/2 \rfloor = 499$. Divisible by $5$: $\lfloor 999/5 \rfloor = 199$. Divisible by $10$: $\lfloor 999/10 \rfloor = 99$. The count of numbers divisible by $2$ or $5$ is $499 + 199 - 99 = 599$. Subtract this from $999$ to get $400$.
  2. For part (b), include $7$. Divisible by $7$: $\lfloor 999/7 \rfloor = 142$. Divisible by $14$: $\lfloor 999/14 \rfloor = 71$. Divisible by $35$: $\lfloor 999/35 \rfloor = 28$. Divisible by $70$: $\lfloor 999/70 \rfloor = 14$. The count of numbers divisible by $2, 5,$ or $7$ is $(499+199+142) - (99+71+28) + 14 = 840 - 198 + 14 = 656$. Subtract from $999$ to get $343$.