The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A353295 Square nearest to the sum of the first n positive squares. 3

%I #29 Jul 15 2022 11:28:54

%S 0,1,4,16,25,49,100,144,196,289,400,484,625,841,1024,1225,1521,1764,

%T 2116,2500,2916,3364,3844,4356,4900,5476,6241,6889,7744,8464,9409,

%U 10404,11449,12544,13689,14884,16129,17689,19044,20449,22201,23716,25600,27556,29241

%N Square nearest to the sum of the first n positive squares.

%H Paolo Xausa, <a href="/A353295/b353295.txt">Table of n, a(n) for n = 0..9999</a>

%F a(n) = A053187(A000330(n)).

%e a(4) = 25 because the sum of the first 4 positive squares is 1 + 4 + 9 + 16 = 30, and the nearest square is 25.

%t nterms=100;Array[Round[Sqrt[#(#+1)(2#+1)/6]]^2&,nterms,0]

%o (Python)

%o from math import isqrt

%o def a(n):

%o s = n*(n+1)*(2*n+1)//6

%o r = isqrt(s)

%o d1, d2 = s-r**2, (r+1)**2-s

%o return r**2 if d1 <= d2 else (r+1)**2

%o print([a(n) for n in range(45)]) # _Michael S. Branicky_, Jun 05 2022

%Y Cf. A000290, A000330, A053187, A351830, A354330.

%K nonn,easy

%O 0,3

%A _Paolo Xausa_, Jun 04 2022

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 6 00:30 EDT 2024. Contains 373110 sequences. (Running on oeis4.)