Trying to count the number of integers $x \le n$ where gcd$\left(x(x+2),30\right)=1$ using the möbius function

65 Views Asked by At

Let:

For $x \le n$ and gcd$(x,30)=1$, the count is:

$$\sum_{i | 30}\left\lfloor\frac{n}{i}\right\rfloor\mu(i) = n - \left\lfloor\frac{n}{2}\right\rfloor - \left\lfloor\frac{n}{3}\right\rfloor - \left\lfloor\frac{n}{5}\right\rfloor + \left\lfloor\frac{n}{6}\right\rfloor + \left\lfloor\frac{n}{10}\right\rfloor +\left\lfloor\frac{n}{15}\right\rfloor - \left\lfloor\frac{n}{30}\right\rfloor$$

For $x \le 30$ and gcd$\left(x(x+2\right),30)=1$, the count is:

$$30 - \left\lfloor\frac{30}{2}\right\rfloor - 2\left\lfloor\frac{30}{3}\right\rfloor - 2\left\lfloor\frac{30}{5}\right\rfloor + 2\left\lfloor\frac{30}{6}\right\rfloor + 2\left\lfloor\frac{30}{10}\right\rfloor +2\left\lfloor\frac{30}{15}\right\rfloor=3$$

I am not clear how to represent this using the möbius function.

I had expected this to work:

$$\sum_{i|30}\left\lfloor\frac{n}{i}\right\rfloor\mu(i) + \sum_{i|30\text{ and }i>2}\left\lfloor\frac{n}{i}\right\rfloor\mu(i)$$

It does not work for $n=30$. I am not clear why, in this case, $-2\left\lfloor\frac{n}{30}\right\rfloor$ is not needed.

How do you correctly count the integers $x \le n$ where gcd$\left(x(x+1),30\right)=1$ using the möbius function?


Edit:

rtybase makes a good point. This can be precisely calculated using:

$$\left\lfloor\frac{n+19}{30}\right\rfloor + \left\lfloor\frac{n+13}{30}\right\rfloor + \left\lfloor\frac{n+1}{30}\right\rfloor$$