[Math] How many integers between $10000$ and $99999$ ( inclusive) are divisible by $3$ or $5$ or $7$

combinationscombinatoricsdiscrete mathematicselementary-set-theory

How many integers between $10000$ and $99999$ (inclusive) are divisible by $3$ or $5$ or $7$ ?


My Try :

Total Integers between $10000$ and $99999$ are $89999$.

$\left\lfloor\frac{89999}{3}\right\rfloor+\left\lfloor\frac{89999}{5}\right\rfloor+\left\lfloor\frac{89999}{7}\right\rfloor$$\left\lfloor\frac{89999}{3\times5}\right\rfloor-\left\lfloor\frac{89999}{3\times7}\right\rfloor-\left\lfloor\frac{89999}{5\times7}\right\rfloor$ + $\left\lfloor\frac{89999}{3\times5\times7}\right\rfloor$ =

$48857$

I don't have an answer for this. Am I right here ?

Best Answer

The number of integers between $3$ and $4$ inclusive divisible by $3$ is not $\lfloor\frac{(4-3+1)}{3}\rfloor=\lfloor\frac{2}{3}\rfloor=0$ but is instead $\lfloor \frac{4}{3}\rfloor - \lfloor\frac{2}{3}\rfloor = 1$.

In the same way, you should not be using $\lfloor \frac{90000}{7}\rfloor$ but instead you should be using $\lfloor\frac{99999}{7}\rfloor - \lfloor\frac{9999}{7}\rfloor$

That is to say, the number of numbers $n$ in the range $a\leq n\leq b$ which is divisible by $7$ are those numbers in the range $1\leq n\leq b$ divisible by seven which are not numbers in the range $1\leq n\leq a-1$ which are divisible by $7$.