A236632 Sum of all divisors of all positive integers <= n minus the total number of divisors of all positive integers <= n.
0, 1, 3, 7, 11, 19, 25, 36, 46, 60, 70, 92, 104, 124, 144, 170, 186, 219, 237, 273, 301, 333, 355, 407, 435, 473, 509, 559, 587, 651, 681, 738, 782, 832, 876, 958, 994, 1050, 1102, 1184, 1224, 1312, 1354, 1432, 1504, 1572, 1618, 1732, 1786, 1873, 1941
Offset: 1
Examples
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.
Links
- Robert Israel, Table of n, a(n) for n = 1..10000
Programs
-
Magma
[(&+[DivisorSigma(1, k) - DivisorSigma(0, k) : k in [1..n]]): n in [1..60]]; // Vincenzo Librandi, Aug 02 2019
-
Maple
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 N:= 1000: # to get a(1) to a(N) A065608:= Vector(N): for a from 1 to floor(sqrt(N)) do for b from a to N/a do if b = a then A065608[a*b] := A065608[a*b] + a - 1 else A065608[a*b] := A065608[a*b] + a + b - 2; fi od od: ListTools:-PartialSums(convert(A065608,list)); # Robert Israel, May 16 2016
-
Mathematica
Table[Sum[Floor[n/i]*Floor[(n - i)/i], {i, n}]/2, {n, 50}] (* Wesley Ivan Hurt, Jan 30 2016 *) Table[Sum[Binomial[Floor[n/i], 2], {i, n}], {n, 51}] (* Michael De Vlieger, May 15 2016 *) Accumulate@ Table[DivisorSum[n, # - 1 &], {n, 51}] (* or *) Table[Sum [(k - 1) Floor[n/k], {k, n}], {n, 51}] (* Michael De Vlieger, Apr 03 2017 *)
-
PARI
a(n) = sum(i=1, n, sigma(i)) - sum(i=1, n, numdiv(i)); \\ Michel Marcus, Feb 01 2014
-
Python
from math import isqrt 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
Formula
a(n) = (1/2) * Sum_{i=1..n} floor(n/i) * floor((n-i)/i). - Wesley Ivan Hurt, Jan 30 2016
a(n) = Sum_{i=1..n} binomial(floor(n/i),2). - Wesley Ivan Hurt, May 08 2016
a(n) = Sum_{k=1..n} (k-1) * floor(n/k). - Wesley Ivan Hurt, Apr 02 2017