TITLE: Prove $\sum\limits_{n \leq x, \gcd(n,k)=1}\frac{1}{n} = \sum\limits_{d|k}\frac{\mu}{d}\log x + O(1)$
QUESTION [5 upvotes]: given $x \in \mathbb{R}$, $k \in \mathbb{N}$\
Let $A$ be the set of positive integers at most $x$ but coprime to $k$
Let $\mu$ be the mobius function, show the following
$$\displaystyle\sum_{n \in A}\dfrac{1}{n} = \Big(\sum_{d|k}\dfrac{\mu(d)}{d}\Big)\log x + O(1)$$
Can someone give me some hint on this. I tried to rewrite $LHS$ with
$$\displaystyle\sum_{n \in A}\dfrac{1}{n} = \sum_{n=1}^{\lfloor{x}\rfloor}
\dfrac{1}{n}\Big(\sum_{d|gcd(n,k)}\mu(d)\Big)$$
Then use Abel summation, but I feel like this is not the right direction.

REPLY [2 votes]: We use the fact that
\[1_{(n,k) = 1} = \sum_{d \mid (n,k)} \mu(d).\]
It follows that
\[\sum_{\substack{n \leq x \\ (n,k) = 1}} \frac{1}{n} = \sum_{n \leq x} \sum_{d \mid (n,k)} \frac{\mu(d)}{n}.\]
The condition $d \mid (n,k)$ is the same as the two conditions $d \mid k$ and $n \equiv 0 \pmod{d}$. So we may interchange the order of summation, yielding
\[\sum_{\substack{n \leq x \\ (n,k) = 1}} \frac{1}{n} = \sum_{d \mid k} \mu(d) \sum_{\substack{n \leq x \\ n \equiv 0 \pmod{d}}} \frac{1}{n}.\]
We make the change of variables $m = \frac{n}{d}$, so that the inner sum is
\[\frac{1}{d} \sum_{m \leq \frac{x}{d}} \frac{1}{m}.\]
Now we use the fact that this sum is $\log \frac{x}{d} + \gamma_0 + O\left(\frac{d}{x}\right)$. So the original sum is
\[\sum_{d \mid k} \frac{\mu(d)}{d} \log x - \sum_{d \mid k} \frac{\mu(d) \log d}{d} + \gamma_0 \sum_{d \mid k} \frac{\mu(d)}{d} + O\left(\frac{1}{x} \sum_{d \mid k} |\mu(d)|\right).\]