OFFSET
1,3
COMMENTS
Partial sums of A049766.
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
MAPLE
N:= 100: # for a(1)..a(N)
S:= [seq(NumberTheory:-SumOfDivisors(i, 1), i=1..N+1)]:
SS:= ListTools:-PartialSums(S):
S2:= [seq(i*S[i], i=1..N+1)]:
SS2:= ListTools:-PartialSums(S2):
f:= n -> 1/2*n^2*(n+1) - (n+1)*SS[n+1]+SS2[n+1]:
map(f, [$1..N]); # Robert Israel, Dec 20 2023
MATHEMATICA
a[n_]:=n^2(n+1)/2-Sum[DivisorSigma[1, i](n-i+1), {i, n+1}]; Array[a, 47, 0] (* Stefano Spezia, Nov 17 2023 *)
PROG
(Python)
from sympy import divisor_sigma
A002411 = lambda n: ((n*n)*(n+1))>>1
A175254 = lambda n: sum(divisor_sigma(i) * (n-i+1) for i in range(1, n+1))
print([a(n) for n in range(1, 53)])
(Python)
from math import isqrt
def A367379(n): return (n**2*(n+1)>>1)-(((s:=isqrt(n))**2*(s+1)*((s+1)*(2*s+1)-6*(n+1))>>1) + sum((q:=n//k)*(-k*(q+1)*(3*k+2*q+1)+3*(n+1)*(2*k+q+1)) for k in range(1, s+1)))//6 # Chai Wah Wu, Dec 20 2023
(PARI) a(n) = sum(j=1, n, sum(i=1, n, j % i)); \\ Michel Marcus, Nov 16 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Darío Clavijo, Nov 15 2023
STATUS
approved