login
a(n) = Sum_{k=1..n} floor(n/k)^2.
19

%I #60 Oct 22 2023 00:37:23

%S 1,5,11,22,32,52,66,92,115,147,169,219,245,289,333,390,424,496,534,

%T 612,672,740,786,898,957,1037,1113,1219,1277,1413,1475,1595,1687,1791,

%U 1883,2056,2130,2246,2354,2526,2608,2792,2878,3040,3190,3330,3424,3662,3773

%N a(n) = Sum_{k=1..n} floor(n/k)^2.

%C a(n) is the number of common divisors of integers 1<=i,j<=n over all ordered pairs (i,j). - _Geoffrey Critzer_, Jan 15 2015

%D J. V. Uspensky and M. A. Heaslet, Elementary Number Theory, McGraw-Hill, NY, 1939, p. 98.

%H Seiichi Manyama, <a href="/A222548/b222548.txt">Table of n, a(n) for n = 1..10000</a>

%H MathOverflow, <a href="https://mathoverflow.net/questions/94827/the-second-moment-of-a-sum-of-floor-functions">The Second Moment of a Sum of Floor Functions</a>, 2012.

%F a(n) = zeta(2)*n^2 + O(n log n).

%F a(n) = 2*A024916(n) - A006218(n). - _Vaclav Kotesovec_, Sep 02 2018

%F G.f.: (1/(1 - x)) * Sum_{k>=1} (2*k - 1) * x^k/(1 - x^k). - _Ilya Gutkovskiy_, Jul 16 2019

%F a(n) = Sum_{d=1..n} (2*d-1)*floor(n/d). [Uspensky and Heaslet] - _Michael Somos_, Feb 16 2020

%F a(n) = Sum_{k=1..n} Sum_{d|k} floor(n/d). - _Ridouane Oudra_, Jul 16 2020

%F a(n) = Sum_{i=1..n} Sum_{j=1..n} tau(gcd(i,j)). - _Ridouane Oudra_, Nov 23 2021

%t Table[Sum[Floor[n/k]^2, {k, n}], {n, 50}] (* _T. D. Noe_, Feb 26 2013 *)

%t Table[nn = n;Total[Level[Table[Table[DivisorSigma[0, GCD[i, j]], {i, 1, nn}], {j, 1, nn}], {2}]], {n, 1, 49}] (* _Geoffrey Critzer_, Jan 15 2015 *)

%t Table[Sum[2*DivisorSigma[1, k] - DivisorSigma[0, k], {k, 1, n}], {n, 1, 50}] (* _Vaclav Kotesovec_, Sep 02 2018 *)

%o (PARI) a(n)=sum(k=1,n,(n\k)^2)

%o (Magma) [&+[Floor(n/k)^2:k in [1..n] ]: n in [1..40]]; // _Marius A. Burtea_, Jul 16 2019

%o (Python)

%o from math import isqrt

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

%Y Cf. A013661, A018806, A024916, A153818.

%Y Similar sequences for Sum_{k=1..n} floor(n/k)^m: A006218 (m=1), this sequence (m=2), A318742 (m=3), A318743 (m=4), A318744 (m=5).

%K nonn

%O 1,2

%A _Benoit Cloitre_, Feb 24 2013