login
Sum of all divisors of all positive integers <= n minus the total number of divisors of all positive integers <= n.
3

%I #44 Oct 23 2023 10:29:48

%S 0,1,3,7,11,19,25,36,46,60,70,92,104,124,144,170,186,219,237,273,301,

%T 333,355,407,435,473,509,559,587,651,681,738,782,832,876,958,994,1050,

%U 1102,1184,1224,1312,1354,1432,1504,1572,1618,1732,1786,1873,1941

%N Sum of all divisors of all positive integers <= n minus the total number of divisors of all positive integers <= n.

%H Robert Israel, <a href="/A236632/b236632.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = A024916(n) - A006218(n).

%F a(n) = (1/2) * Sum_{i=1..n} floor(n/i) * floor((n-i)/i). - _Wesley Ivan Hurt_, Jan 30 2016

%F a(n) = Sum_{i=1..n} binomial(floor(n/i),2). - _Wesley Ivan Hurt_, May 08 2016

%F a(n) = Sum_{k=1..n} (k-1) * floor(n/k). - _Wesley Ivan Hurt_, Apr 02 2017

%F a(n) = (1/2)*(A222548(n) - A006218(n)). - _Ridouane Oudra_, Aug 01 2019

%e For n = 6 the sets of divisors of the positive integers <= 6 are {1}, {1, 2}, {1, 3}, {1, 2, 4}, {1, 5}, {1, 2, 3, 6}. There are 14 total divisors and their sum is 1 + 3 + 4 + 7 + 6 + 12 = 33, so a(6) = 33 - 14 = 19.

%p A236632:=n->(1/2)*add(floor(n/i)*floor((n-i)/i), i=1..n): seq(A236632(n), n=1..100); # _Wesley Ivan Hurt_, Jan 30 2016

%p N:= 1000: # to get a(1) to a(N)

%p A065608:= Vector(N):

%p for a from 1 to floor(sqrt(N)) do for b from a to N/a do

%p if b = a then

%p A065608[a*b] := A065608[a*b] + a - 1

%p else

%p A065608[a*b] := A065608[a*b] + a + b - 2;

%p fi

%p od od:

%p ListTools:-PartialSums(convert(A065608,list)); # _Robert Israel_, May 16 2016

%t Table[Sum[Floor[n/i]*Floor[(n - i)/i], {i, n}]/2, {n, 50}] (* _Wesley Ivan Hurt_, Jan 30 2016 *)

%t Table[Sum[Binomial[Floor[n/i], 2], {i, n}], {n, 51}] (* _Michael De Vlieger_, May 15 2016 *)

%t Accumulate@ Table[DivisorSum[n, # - 1 &], {n, 51}] (* or *)

%t Table[Sum [(k - 1) Floor[n/k], {k, n}], {n, 51}] (* _Michael De Vlieger_, Apr 03 2017 *)

%o (PARI) a(n) = sum(i=1, n, sigma(i)) - sum(i=1, n, numdiv(i)); \\ _Michel Marcus_, Feb 01 2014

%o (Magma) [(&+[DivisorSigma(1, k) - DivisorSigma(0, k) : k in [1..n]]): n in [1..60]]; // _Vincenzo Librandi_, Aug 02 2019

%o (Python)

%o from math import isqrt

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

%Y Partial sums of A065608.

%Y Cf. A000005, A000203, A006218, A024916, A222548.

%K nonn,easy

%O 1,3

%A _Omar E. Pol_, Jan 31 2014