Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #16 Oct 21 2023 17:06:33
%S 0,0,2,3,12,13,33,40,66,81,135,135,212,249,319,354,489,511,681,725,
%T 876,981,1233,1235,1509,1660,1920,2032,2437,2472,2936,3091,3488,3755,
%U 4275,4290,4955,5292,5854,6024,6843,6968,7870,8190,8839,9340,10420,10442,11568,12038,13014,13474,14851,15098,16436
%N a(n) = n^2 * (n + 1)/2 - Sum_{k=1..n} sigma_2(k).
%H Amiram Eldar, <a href="/A309176/b309176.txt">Table of n, a(n) for n = 1..10000</a>
%F G.f.: x * (1 + 2*x)/(1 - x)^4 - (1/(1 - x)) * Sum_{k>=1} k^2 * x^k/(1 - x^k).
%F a(n) = Sum_{k=1..n} (n mod k) * k.
%F a(n) = A002411(n) - A064602(n).
%t Table[n^2 (n + 1)/2 - Sum[DivisorSigma[2, k], {k, 1, n}], {n, 1, 55}]
%t nmax = 55; CoefficientList[Series[x (1 + 2 x)/(1 - x)^4 - 1/(1 - x) Sum[k^2 x^k/(1 - x^k), {k, 1, nmax}], {x, 0, nmax}], x] // Rest
%t Table[Sum[Mod[n, k] k, {k, 1, n}], {n, 1, 55}]
%o (PARI) a(n) = n^2*(n+1)/2 - sum(k=1, n, sigma(k, 2)); \\ _Michel Marcus_, Sep 18 2021
%o (Python)
%o from math import isqrt
%o def A309176(n): return (n**2*(n+1)>>1)+((s:=isqrt(n))**2*(s+1)*(2*s+1)-sum((q:=n//k)*(6*k**2+q*(2*q+3)+1) for k in range(1,s+1)))//6 # _Chai Wah Wu_, Oct 21 2023
%Y Cf. A000326, A001157, A004125, A048158, A051126, A154585, A256532.
%Y Cf. A002411, A064602.
%K nonn
%O 1,3
%A _Ilya Gutkovskiy_, Jul 15 2019