login
a(n) = (1/2) * Sum_{d divides n} abs(n/d-d).
11

%I #21 Jan 01 2024 13:02:24

%S 0,1,2,3,4,6,6,9,8,12,10,16,12,18,16,21,16,27,18,28,24,30,22,40,24,36,

%T 32,42,28,50,30,49,40,48,36,65,36,54,48,66,40,72,42,70,60,66,46,92,48,

%U 77,64,84,52,96,60,92,72,84,58,126,60,90,82,105,72,120,66,112,88,114,70

%N a(n) = (1/2) * Sum_{d divides n} abs(n/d-d).

%C Also, Sum_{i|n, sqrt(n)<i<=n} i - Sum_{i|n, 1<=i<sqrt(n)} i.

%D H. J. S. Smith, Report on the Theory of Numbers, reprinted in Vol. 1 of his Collected Math. Papers, Chelsea, NY, 1979, see p. 323.

%H Alois P. Heinz, <a href="/A079667/b079667.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = A070038(n) - A066839(n).

%F G.f.: Sum_{k>0} x^(k^2+k)/(1-x^k)^2 . - _Michael Somos_, Nov 19 2005

%t Table[DivisorSum[n, Abs[n/# - #] &, # <= Sqrt[n] &], {n, 71}] (* _Michael De Vlieger_, Mar 17 2021 *)

%o (PARI) a(n)=if(n<2, 0, sumdiv(n,d, abs(n/d-d))/2) /* _Michael Somos_, Nov 19 2005 */

%o (SageMath)

%o def A079667(n): return sum(n//d - d for d in divisors(n) if d*d <= n)

%o print([A079667(n) for n in range(1, 72)]) # _Peter Luschny_, Jan 01 2024

%Y Cf. A060866, A116589.

%K easy,nonn

%O 1,3

%A _Vladeta Jovovic_, Jan 25 2003