[Math] How many numbers in between $1$ and $250$ are not divisible by $2, 3, 5$ or $7$

combinatoricsdiscrete mathematicsdivisibilityelementary-set-theoryinclusion-exclusion

How many numbers in between $1$ and $250$ are not divisible by $2, 3, 5$ or $7$? Using the Inclusion Exclusion Principle, I got the answer to be $57$ (i.e. $250-193$), but I'm worried I might have screwed up the arithmetic. Is there a quick and easy way to check whether long calculations like these are right?

Best Answer

I will first consider all integers up to $210$, as it is the L.C.M. of $2$, $3$, $5$ and $7$. The number of integers from $1$ to $210$ which are not divisible by $2$, $3$, $5$ or $7$ is

$$210-\frac{210}{2}-\frac{210}{3}-\frac{210}{5}-\frac{210}{7}+\frac{210}{6}+\frac{210}{10}+\frac{210}{14}+\frac{210}{15}+\frac{210}{21}+\frac{210}{35}-\frac{210}{30}-\frac{210}{42}-\frac{210}{70}-\frac{210}{105}+\frac{210}{210}$$

which is equal to

$$210\left(1-\frac{1}{2}\right)\left(1-\frac{1}{3}\right)\left(1-\frac{1}{5}\right)\left(1-\frac{1}{7}\right)=48$$

The integers from $211$ to $250$ can be replaced by $1$ to $40$. I prefer to simply list out all integers satisfying the conditions: $1$, $11$, $13$, $17$, $19$, $23$, $29$, $31$, $37$.

So, there are $48+9=57$ such integers.