OFFSET
1,3
FORMULA
MATHEMATICA
Table[Sum[(-1)^(k + 1) k Ceiling[n/k], {k, 1, n}], {n, 1, 75}]
Table[(-1)^(n + 1) Ceiling[n/2] + Sum[DivisorSum[k, (-1)^(# + 1) # &], {k, 1, n - 1}], {n, 1, 75}]
nmax = 75; CoefficientList[Series[x/(1 - x) (1/(1 + x)^2 + Sum[(-1)^(k + 1) k x^k/(1 - x^k), {k, 1, nmax}]), {x, 0, nmax}], x] // Rest
PROG
(PARI) a(n) = sum(k=1, n, (-1)^(k+1)*k*ceil(n/k)); \\ Michel Marcus, May 26 2020
(Python)
from math import isqrt
def A333505(n): return ((s:=isqrt(m:=n-1>>1))**2*(s+1)-sum((q:=m//k)*((k<<1)+q+1) for k in range(1, s+1))<<1)-((t:=isqrt(n-1))**2*(t+1)-sum((q:=(n-1)//k)*((k<<1)+q+1) for k in range(1, t+1))>>1) + (m+1 if n&1 else -m-1) # Chai Wah Wu, Oct 30 2023
CROSSREFS
KEYWORD
sign
AUTHOR
Ilya Gutkovskiy, May 25 2020
STATUS
approved