OFFSET
1,3
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
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
EXAMPLE
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.
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
else
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 *)
PROG
(PARI) a(n) = sum(i=1, n, sigma(i)) - sum(i=1, n, numdiv(i)); \\ Michel Marcus, Feb 01 2014
(Magma) [(&+[DivisorSigma(1, k) - DivisorSigma(0, k) : k in [1..n]]): n in [1..60]]; // Vincenzo Librandi, Aug 02 2019
(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
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Omar E. Pol, Jan 31 2014
STATUS
approved