login
a(n) = Sum_{k=1..n} k^2*(floor(n/k) - 1).
5

%I #16 Oct 21 2023 17:10:12

%S 0,1,2,7,8,22,23,44,54,84,85,151,152,206,241,326,327,458,459,605,664,

%T 790,791,1065,1091,1265,1356,1622,1623,2023,2024,2365,2496,2790,2865,

%U 3480,3481,3847,4026,4636,4637,5373,5374,6000,6341,6875,6876,7982,8032,8787,9086,9952,9953,11137,11284

%N a(n) = Sum_{k=1..n} k^2*(floor(n/k) - 1).

%C Sum of all squares of proper divisors of all positive integers <= n.

%C Total volume of all rectangular prisms with dimensions (x, x, z) and integers x and y, such that x + y = n, 0 < x <= y, and z = floor(y/x). - _Wesley Ivan Hurt_, Dec 21 2020

%H <a href="/index/Su#sums_of_divisors">Index entries for sequences related to sums of divisors</a>

%F G.f.: -x*(1 + x)/(1 - x)^4 + (1/(1 - x))*Sum_{k>=1} k^2*x^k/(1 - x^k).

%F a(n) = A064602(n) - A000330(n).

%F a(n) = Sum_{k=1..n} A067558(k).

%F a(n) = Sum_{k=1..n} (A001157(k) - A000290(k)).

%F a(p^k) = a(p^k-1) + (p^(2*k) - 1)/(p^2 - 1), for p is prime.

%F a(n) ~ ((zeta(3) - 1)/3)*n^3.

%F a(n) = Sum_{k=1..floor(n/2)} k^2 * floor((n-k)/k). - _Wesley Ivan Hurt_, Dec 21 2020

%e For n = 7 the proper divisors of the first seven positive integers are {0}, {1}, {1}, {1, 2}, {1}, {1, 2, 3}, {1} so a(7) = 0^2 + 1^2 + 1^2 + 1^2 + 2^2 + 1 ^2 + 1^2 + 2^2 + 3^2 + 1^2 = 23.

%t Table[Sum[k^2 (Floor[n/k] - 1), {k, 1, n}], {n, 55}]

%t Table[Sum[DivisorSigma[2, k] - k^2, {k, 1, n}], {n, 55}]

%o (PARI) a(n) = sum(k=1, n, k^2*(floor(n/k)-1)) \\ _Felix Fröhlich_, Dec 20 2016

%o (Python)

%o from math import isqrt

%o def A279847(n): return (-n*(n+1)*(2*n+1)-(s:=isqrt(n))**2*(s+1)*(2*s+1) + sum((q:=n//k)*(6*k**2+q*(2*q+3)+1) for k in range(1,s+1)))//6 # _Chai Wah Wu_, Oct 21 2023

%Y Cf. A000290, A000330, A001157, A064602, A067558, A153485.

%K nonn,easy

%O 1,3

%A _Ilya Gutkovskiy_, Dec 20 2016