How many integers in the range $\leq N$ are divisible by both $2$ and $3$ but are not divisible by whole powers $>1$ of $2$ and $3$ i.e. not divisible by $2^2,3^2, 2^3,3^3, \ldots ?$
I hope by using the inclusion–exclusion principle one may derive such a formula and part of the formula has a form $$ N-\left[\frac{N}{2} \right]+\left[\frac{N}{2^2} \right]-\left[\frac{N}{2^3} \right]+\cdots -\left[\frac{N}{3} \right]+\left[\frac{N}{3^2} \right]-\left[\frac{N}{3^3} \right]+\cdots+\left[\frac{N}{2 \cdot 3} \right]+\text{some terms like as $\pm \left[\frac{N}{2^i \cdot 3^j} \right]$} $$
Question. What is the exact sign for a term $ \left[\frac{N}{2^i \cdot 3^j} \right]$?
We want to count those numbers divisible by $6=2\cdot3$, but not those divisible by $12=2^2\cdot3$ or $18=2\cdot3^2$. However, if we count both those numbers divisible by $12$ and those divisible by $18$, we've counted those divisible by $36$ twice. Therefore, the count should be $$ \left\lfloor\frac N6\right\rfloor-\left\lfloor\frac N{12}\right\rfloor-\left\lfloor\frac N{18}\right\rfloor+\left\lfloor\frac N{36}\right\rfloor $$