TITLE: How to compute sum of sum of gcd of factor pairs of a number upto a large number efficiently?
QUESTION [6 upvotes]: Define
$$f(n)=\sum_{d|n}gcd(d,\frac{n}{d})$$
$$F(x)=\sum_{n=1}^xf(n)$$ for natural numbers d,n and x.
I would like to know if there is some simplified form of $F(x)$ in terms of arithmetic functions, or atleast some computationally feasible form for large $x$.($x$ is of the order $10^{15}$ or higher).
A brute force approach is not efficient because of the $d|n$.Exchanging the summations is a slight improvement.But even after that I can't evaluate $F(x)$ for $x>10^7$ within reasonable time for which I believe a total mathematical algorithmic change is needed.
How can we manipulate the given expression so that the computation is reasonably fast?
EDIT:I just found out this is one of the Project Euler problems-problem no. 530

REPLY [2 votes]: It can be proved that $\displaystyle \sum_{d\mid n} (d,n/d) = \sum_{d^2\mid n}\tau(n/d^2)\varphi(d)$.
So one can show that $\displaystyle F(x) = \sum_{n\le \sqrt{x}}\varphi(n)\sum_{m \le x/n^2} \left\lfloor\frac{x}{n^2 m}\right\rfloor$.
This is the best i can do, but this is still computationally unfeasible for $x \approx 10^{15}$.