%I #34 Dec 09 2023 01:43:27
%S 0,1,3,5,10,10,21,21,30,31,55,38,78,64,73,85,136,91,171,115,150,166,
%T 253,150,260,235,273,236,406,220,465,341,388,409,451,335,666,514,549,
%U 451,820,451,903,610,640,760,1081,598,1050,781,955,863,1378,820,1165
%N a(n) = (1/2) * Sum_{d|n, d > 1} d * phi(d).
%C Sum of numerators of the reduced fractions 1/n, ..., (n-1)/n. Note that if n is a prime p this is p*(p-1)/2 as all fractions are already reduced. For 1/n, ..., n/n, see A057661.
%H Robert Israel, <a href="/A332049/b332049.txt">Table of n, a(n) for n = 1..10000</a>
%F G.f.: (1/2) * Sum_{k>=2} phi(k^2) * x^k / (1 - x^k).
%F a(n) = Sum_{k=1..n-1} k / gcd(n,k).
%F a(n) = (sigma_2(n^2) - sigma_1(n^2)) / (2 * sigma_1(n^2)).
%F a(n) = Sum_{d|n, d > 1} A023896(d).
%F a(n) = A057661(n) - 1 = (A057660(n) - 1) / 2.
%e For n = 5, fractions are 1/5, 2/5, 3/5, 4/5, sum of numerators is 10.
%e For n = 8, fractions are 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, sum of numerators is 21.
%p N:= 100: # for a(1)..a(N)
%p V:= Vector(N):
%p for d from 2 to N do
%p v:= d*numtheory:-phi(d)/2;
%p R:= [seq(i,i=d..N,d)];
%p V[R]:= V[R] +~ v
%p od:
%p convert(V,list); # _Robert Israel_, Feb 07 2020
%t Table[(1/2) Sum[If[d > 1, d EulerPhi[d], 0], {d, Divisors[n]}], {n, 1, 55}]
%t nmax = 55; CoefficientList[Series[(1/2) Sum[EulerPhi[k^2] x^k/(1 - x^k), {k, 2, nmax}], {x, 0, nmax}], x] // Rest
%t Table[Sum[k/GCD[n, k], {k, 1, n - 1}], {n, 1, 55}]
%t Table[(DivisorSigma[2, n^2] - DivisorSigma[1, n^2])/(2 DivisorSigma[1, n^2]), {n, 1, 55}]
%o (Magma) [0] cat [(1/2)*&+[ d*EulerPhi(d):d in Set(Divisors(n)) diff {1}]:n in [2..60]]; // _Marius A. Burtea_, Feb 07 2020
%o (PARI) a(n) = sumdiv(n, d, if (d>1, d*eulerphi(d)))/2; \\ _Michel Marcus_, Feb 07 2020
%o (Haskell)
%o toNums a = fmap (numerator . (% a))
%o toNumList a = toNums a [1..(a-1)]
%o sumList = sum . toNumList <$> [2..200]
%Y Cf. A000010, A002618, A006579, A023896, A057660, A057661.
%K nonn,look
%O 1,3
%A _Ilya Gutkovskiy_, Feb 06 2020