OFFSET
1,2
COMMENTS
PROG
(Python)
from math import isqrt
def A294017(n): return (((s:=isqrt(n))**2*(s+1)*((s+1)*((s<<1)+1)-6*(n+1))>>1) + sum((q:=n//k)*(-k*(q+1)*(3*k+(q<<1)+1)+3*(n+1)*((k<<1)+q+1)) for k in range(1, s+1)))//3-n*(n+1)*((n<<1)+1)//6 # Chai Wah Wu, Oct 22 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Omar E. Pol, Oct 22 2017
STATUS
approved