Alternating GCD Sum (noch nicht übersetzt)

Problem 795

For a positive integer n, the function g(n) is defined as

g(n)=ni=1(1)igcd(n,i2)

For example, g(4)=gcd(4,12)+gcd(4,22)gcd(4,32)+gcd(4,42)=1+41+4=6.
You are also given g(1234)=1233.

Let G(N)=Nn=1g(n). You are given G(1234)=2194708.

Find G(12345678).