%I #34 Nov 15 2023 19:43:30
%S 0,0,0,1,2,6,9,17,25,37,50,72,89,117,148,184,220,271,318,382,443,513,
%T 590,688,773,876,988,1113,1237,1388,1526,1693,1860,2044,2241,2459,
%U 2657,2890,3138,3407,3665,3962,4246,4571,4899,5238,5596,5999,6373,6787,7207
%N a(n) = Sum_{k=1..n} Sum_{d=1..k} (k mod d).
%C Previous name was: Sums of sums of remainders when dividing n by k, 0<k<=n.
%C Partial sums of A004125.
%H Robert Israel, <a href="/A072481/b072481.txt">Table of n, a(n) for n = 0..10000</a>
%F a(n) = Sum_{k=1..n} Sum_{d=1..k}(k mod d).
%F a(n) = A000330(n) - A175254(n), n >= 1. - _Omar E. Pol_, Aug 12 2015
%F G.f.: x^2/(1-x)^4 - (1-x)^(-2) * Sum_{k>=1} k*x^(2*k)/(1-x^k). - _Robert Israel_, Aug 13 2015
%F a(n) ~ (1 - Pi^2/12)*n^3/3. - _Vaclav Kotesovec_, Sep 25 2016
%p N:= 200: # to get a(0) to a(N)
%p S:= series(add(k*x^(2*k)/(1-x^k),k=1..floor(N/2))/(1-x)^2, x, N+1):
%p seq((n^3-n)/6 - coeff(S,x,n), n=0..N); # _Robert Israel_, Aug 13 2015
%t a[n_] := n(n+1)(2n+1)/6 - Sum[DivisorSigma[1, k] (n-k+1), {k, 1, n}];
%t Table[a[n], {n, 0, 50}] (* _Jean-François Alcover_, Mar 08 2019, after _Omar E. Pol_ *)
%o (Python)
%o for n in range(99):
%o s = 0
%o for k in range(1,n+1):
%o for d in range(1,k+1):
%o s += k % d
%o print(str(s), end=',')
%o (Python)
%o from math import isqrt
%o def A072481(n): return (n*(n+1)*((n<<1)+1)-((s:=isqrt(n))**2*(s+1)*((s+1)*((s<<1)+1)-6*(n+1))>>1)-sum((q:=n//k)*(-k*(q+1)*(3*k+(q<<1)+1)+3*(n+1)*((k<<1)+q+1)) for k in range(1,s+1)))//6 # _Chai Wah Wu_, Oct 22 2023
%o (PARI) a(n) = sum(k=1, n, sum(d=1, k, k % d)); \\ _Michel Marcus_, Feb 11 2014
%Y Cf. A224923, A224924.
%K nonn
%O 0,5
%A _Reinhard Zumkeller_, Aug 02 2002
%E New name and a(0) from _Alex Ratushnyak_, Feb 10 2014