Some questions about the arithmetic function $\,g(n)=\sum_{(k,n)=1}\tau(k)$ Given the arithmetic function $\tau(n)=\sum_{d|n}1$, let's define the function
$$g(n)=\sum_{1\le k\le n\;(k,n)=1}\tau(k)$$
For $n\ge1$ the first values of $g(n)$ are $1,1,3,3,8,3,14,7,14,8,...$
Analyzing the sequence of the first $10^4$ values of the function, I could see that:

*

*$g(n)=n\,$ only for $\,n=3,40,576,606$;

*if the argument of the function is a prime $(p)$, we have $\,g(p)\sim p\cdot \log(p)$.

I ask if it's possible to prove that
$$\lim_{k\rightarrow\infty}\frac{g(p_k)}{p_k\cdot \log(p_k)}=\lim_{k\rightarrow\infty}\frac{\sum_{i=1}^{p_k-1}\tau(i)}{k\cdot \log\,k\cdot(\log\,k+\log\,\log\,k)}=1$$
Many thanks.
[same question here]
 A: In general, the summatory function
$$
S_q(x) = \sum_{\substack{n\leq x\\ (n,q)=1}} \tau(n)
$$
can be evaluated asymptotically via a standard computation using Perron's Formula. This sum comes up when studying the divisor function in coprime residue classes (see this paper, for instance). I won't write out all the details, but one can show that
$$
S_q(x) = x \left(\frac{\phi(q)}{q}\right)^2\left(\log x + 2\gamma-1+2\sum_{p\mid q} \frac{\log p}{p-1}\right) + O\left(\tau(q)x^{\delta}(\log x)^2\right)
$$
for some $\delta < 1$. Taking $x=q=n$, we find that in general
$$
\sum_{\substack{k\leq n\\ (k,n)=1}} \tau(k) \sim \frac{\phi(n)^2}{n}\log n.
$$
When $n$ is prime, this gives the desired limit.
Edit: It should be noted that
$$
\sum_{p\mid n} \frac{\log p}{p-1} \ll \log\log n,
$$
so this doesn't contribute to the leading order term.
A: When $p$ is prime we have $$g(p) = \sum_{k=1}^{p-1}\tau(k) = \sum_{k=1}^{p}\tau(k)-2 = p \log p + p(2\gamma -1) + O(\sqrt{p})$$
from the know result for the divisor summatory function.
