OFFSET
1,2
MATHEMATICA
a[n_]:=Sum[ (-1)^k*k^2*Floor[n/k], {k, n}]; Array[a, 49] (* Stefano Spezia, Oct 29 2023 *)
PROG
(Python)
from math import isqrt
def A366915(n): return (-(t:=isqrt(m:=n>>1))**2*(t+1)*((t<<1)+1)+sum((q:=m//k)*(6*k**2+q*((q<<1)+3)+1) for k in range(1, t+1))<<2)//3+((s:=isqrt(n))**2*(s+1)*((s<<1)+1)-sum((q:=n//k)*(6*k**2+q*((q<<1)+3)+1) for k in range(1, s+1)))//6
(PARI) a(n) = sum(k=1, n, (-1)^k*k^2*(n\k)); \\ Michel Marcus, Oct 29 2023
CROSSREFS
KEYWORD
sign
AUTHOR
Chai Wah Wu, Oct 28 2023
STATUS
approved