login
A366915
a(n) = Sum_{k=1..n} (-1)^k*k^2*floor(n/k).
4
-1, 2, -8, 11, -15, 15, -35, 48, -43, 35, -87, 103, -67, 83, -177, 162, -128, 145, -217, 277, -223, 143, -387, 443, -208, 302, -518, 432, -410, 370, -592, 771, -449, 421, -879, 850, -520, 566, -1134, 1024, -658, 842, -1008, 1310, -1056, 534, -1676, 1714, -737
OFFSET
1,2
FORMULA
a(n) = 8*A064602(floor(n/2))-A064602(n).
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
Sequence in context: A360649 A297831 A045086 * A064105 A129516 A220269
KEYWORD
sign
AUTHOR
Chai Wah Wu, Oct 28 2023
STATUS
approved