login
A309176
a(n) = n^2 * (n + 1)/2 - Sum_{k=1..n} sigma_2(k).
2
0, 0, 2, 3, 12, 13, 33, 40, 66, 81, 135, 135, 212, 249, 319, 354, 489, 511, 681, 725, 876, 981, 1233, 1235, 1509, 1660, 1920, 2032, 2437, 2472, 2936, 3091, 3488, 3755, 4275, 4290, 4955, 5292, 5854, 6024, 6843, 6968, 7870, 8190, 8839, 9340, 10420, 10442, 11568, 12038, 13014, 13474, 14851, 15098, 16436
OFFSET
1,3
LINKS
FORMULA
G.f.: x * (1 + 2*x)/(1 - x)^4 - (1/(1 - x)) * Sum_{k>=1} k^2 * x^k/(1 - x^k).
a(n) = Sum_{k=1..n} (n mod k) * k.
a(n) = A002411(n) - A064602(n).
MATHEMATICA
Table[n^2 (n + 1)/2 - Sum[DivisorSigma[2, k], {k, 1, n}], {n, 1, 55}]
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
Table[Sum[Mod[n, k] k, {k, 1, n}], {n, 1, 55}]
PROG
(PARI) a(n) = n^2*(n+1)/2 - sum(k=1, n, sigma(k, 2)); \\ Michel Marcus, Sep 18 2021
(Python)
from math import isqrt
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
KEYWORD
nonn
AUTHOR
Ilya Gutkovskiy, Jul 15 2019
STATUS
approved