I have the following summation:
$$F(k)=\sum\limits_{n=1}^k\sum\limits_{d|n}\gcd\left({d},{\frac{n}{d}}\right)$$
This is nearly impossible to compute (using coding) for large numbers, due to the time it'd take.
It's been suggested that the above summation can be simplified to this:
$$F(k)=\sum_{d=1}^{d^2\leqslant k}\ \sum_{n=1}^{nd\leqslant k}\gcd({d},{n})$$
I've tried testing the simplification, and it doesn't work. For instance, F(10) gives an output of 22 instead of 32.
How do I simplify the first summation?
Stuff here might be relevant, but I'm not sure: Wikipedia: Divisor function.
EDIT: Algorithm for thefunkyjunky's suggestion:
long k = 10;
for (long d = 1; d*d <= k; d++) {
for(long n = 1; n*d <= k; n++) {
if (d*d <= n) result = result.add(BigInteger.valueOf(GCD(d,n)));
}
}

gcd()... – vonbrand Dec 27 '15 at 23:08