Skip to main content
2 of 2
added 67 characters in body
Seva
  • 23k
  • 2
  • 59
  • 141

The asymptotic you want does not hold just because the "last-term fluctuation" $$ g(n)-g(n-1) = 2\sum_{a=1}^n \gcd(a,n)-n $$ is too large. Indeed, denoting the sum in the right-hand side by $\sigma(n)$, we have $$ \sigma(n) =\sum_{d\mid n} d\varphi(n/d) = n \sum_{d\mid n} \prod_{p\mid(n/d)} \Big(1-\frac1p\Big) = n \sum_{d\mid n} \prod_{p\mid d} \Big(1-\frac1p\Big). $$

If now $n=p_1\dotsb p_k$ is the product of the first $k$ primes, then $$ \sigma(n) = \Big(2-\frac1{p_1}\Big)\dotsb\Big(2-\frac1{p_k}\Big)\,n \ge (3/2)^k n $$ while, using the prime number theorem, it is not difficult to see that $k\ge c\ln n/\ln\ln n$ with an absolute constant $c>0$; hence, $$ \sigma(n) \ge \exp(c'\ln n/\ln\ln n)\,n,\ n=p_1\dotsb p_k. $$ On the other hand, for $n$ prime we have $$ \sigma(n) = 2n-1. $$ It follows that one cannot get an asymptotic for $g(n)$ with the remainder term better than $O(\exp(c'\ln n/\ln\ln n)\,n)$.

Seva
  • 23k
  • 2
  • 59
  • 141