OFFSET
1,2
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = m*(m+1)/2 + Sum_{k=1..floor(n/(m+1))} floor(n/k), where m is the largest number such that m*(m+1) <= n, i.e., m=floor((sqrt(4*n+1)-1)/2 ). - Max Alekseyev, Feb 12 2012
From Ridouane Oudra, Nov 02 2024: (Start)
a(n) = r*(r-1)/2 + Sum_{k=1..floor(sqrt(n))} floor(n/k), where r = floor(sqrt(n+1) + 1/2).
a(n) = (1/4)*t*(t-1) + (1/2)*Sum_{k=1..n} floor(n/k), where t = floor(sqrt(4*n + 1)).
MAPLE
seq(add(j, j in {seq(floor(n/i), i=1..n)}), n=1..100); # Ridouane Oudra, Nov 02 2024
MATHEMATICA
a[n_] := With[{m = Quotient[Floor@Sqrt[4n+1]-1, 2]}, m(m+1)/2 + Sum[ Quotient[n, k], {k, 1, Quotient[n, m+1]}]];
Array[a, 100] (* Jean-François Alcover, Nov 20 2020, after Max Alekseyev *)
PROG
(PARI) { a(n) = m=(sqrtint(4*n+1)-1)\2; m*(m+1)/2 + sum(k=1, n\(m+1), n\k) } \\ Max Alekseyev, Feb 12 2012
(Python)
from math import isqrt
def A051201(n): return ((m:=isqrt((n<<2)+1)+1>>1)*(m-1)>>1)+sum(n//k for k in range(1, n//m+1)) # Chai Wah Wu, Oct 31 2023
CROSSREFS
KEYWORD
nonn,changed
AUTHOR
STATUS
approved