login
A350221
a(n) = Sum_{k=1..n} (-1)^(k+1) * floor((n/k)^2).
3
1, 3, 8, 12, 21, 29, 40, 52, 67, 83, 100, 116, 140, 160, 185, 210, 237, 264, 298, 327, 363, 397, 435, 472, 514, 557, 602, 644, 690, 741, 791, 837, 897, 950, 1009, 1063, 1126, 1185, 1253, 1313, 1381, 1450, 1521, 1593, 1667, 1739, 1820, 1894, 1973, 2054, 2140
OFFSET
1,2
FORMULA
a(n) = A309081(n^2).
MATHEMATICA
a[n_] := Sum[(-1)^(k + 1)*Floor[(n/k)^2], {k, 1, n}]; Array[a, 50] (* Amiram Eldar, Dec 20 2021 *)
PROG
(PARI) a(n) = sum(k=1, n, (-1)^(k+1)*(n^2\k^2));
(Python)
def A350221(n): return (m:=n**2)+sum(m//k**2 if k&1 else -(m//k**2) for k in range(2, n+1)) # Chai Wah Wu, Oct 27 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Seiichi Manyama, Dec 20 2021
STATUS
approved