OFFSET
0,5
COMMENTS
Previous name was: Sums of sums of remainders when dividing n by k, 0<k<=n.
Partial sums of A004125.
LINKS
Robert Israel, Table of n, a(n) for n = 0..10000
FORMULA
a(n) = Sum_{k=1..n} Sum_{d=1..k}(k mod d).
G.f.: x^2/(1-x)^4 - (1-x)^(-2) * Sum_{k>=1} k*x^(2*k)/(1-x^k). - Robert Israel, Aug 13 2015
a(n) ~ (1 - Pi^2/12)*n^3/3. - Vaclav Kotesovec, Sep 25 2016
MAPLE
N:= 200: # to get a(0) to a(N)
S:= series(add(k*x^(2*k)/(1-x^k), k=1..floor(N/2))/(1-x)^2, x, N+1):
seq((n^3-n)/6 - coeff(S, x, n), n=0..N); # Robert Israel, Aug 13 2015
MATHEMATICA
a[n_] := n(n+1)(2n+1)/6 - Sum[DivisorSigma[1, k] (n-k+1), {k, 1, n}];
Table[a[n], {n, 0, 50}] (* Jean-François Alcover, Mar 08 2019, after Omar E. Pol *)
PROG
(Python)
for n in range(99):
s = 0
for k in range(1, n+1):
for d in range(1, k+1):
s += k % d
print(str(s), end=', ')
(Python)
from math import isqrt
def A072481(n): return (n*(n+1)*((n<<1)+1)-((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)))//6 # Chai Wah Wu, Oct 22 2023
(PARI) a(n) = sum(k=1, n, sum(d=1, k, k % d)); \\ Michel Marcus, Feb 11 2014
CROSSREFS
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Aug 02 2002
EXTENSIONS
New name and a(0) from Alex Ratushnyak, Feb 10 2014
STATUS
approved