cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A053187 Square nearest to n.

This page as a plain text file.
%I A053187 #62 Jun 06 2025 14:47:04
%S A053187 0,1,1,4,4,4,4,9,9,9,9,9,9,16,16,16,16,16,16,16,16,25,25,25,25,25,25,
%T A053187 25,25,25,25,36,36,36,36,36,36,36,36,36,36,36,36,49,49,49,49,49,49,49,
%U A053187 49,49,49,49,49,49,49,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64
%N A053187 Square nearest to n.
%C A053187 Apart from 0, k^2 appears 2k times from a(k^2-k+1) through to a(k^2+k) inclusive.
%H A053187 Reinhard Zumkeller, <a href="/A053187/b053187.txt">Table of n, a(n) for n = 0..10000</a>
%F A053187 a(n) = ceiling((-1 + sqrt(4*n+1))/2)^2. - _Robert Israel_, Aug 01 2014
%F A053187 G.f.: (1/(1-x))*Sum_{n>=0} (2*n+1)*x^(n^2+n+1). - _Robert Israel_, Aug 01 2014.  This is related to the Jacobi theta-function theta'_1(q), see A002483 and A245552.
%F A053187 G.f.: x / (1-x) * Sum_{k>0} (2*k - 1) * x^(k^2 - k). - _Michael Somos_, Jan 05 2015
%F A053187 a(n) = floor(sqrt(n)+1/2)^2. - _Mikael Aaltonen_, Jan 17 2015
%F A053187 Sum_{n>=1} 1/a(n)^2 = 2*zeta(3). - _Amiram Eldar_, Aug 15 2022
%F A053187 a(n) = A000194(n)^2. - _Chai Wah Wu_, Jun 06 2025
%e A053187 a(7) = 9 since 7 is closer to 9 than to 4.
%e A053187 G.f. = x + x^2 + 4*x^3 + 4*x^4 + 4*x^5 + 4*x^6 + 9*x^7 + 9*x^8 + 9*x^9 + ...
%p A053187 seq(ceil((-1+sqrt(4*n+1))/2)^2, n=0..20); # _Robert Israel_, Jan 05 2015
%t A053187 nearestSq[n_] := Block[{a = Floor@ Sqrt@ n}, If[a^2 + a + 1/2 > n, a^2, a^2 + 2 a + 1]]; Array[ nearestSq, 75, 0] (* _Robert G. Wilson v_, Aug 01 2014 *)
%o A053187 (Haskell)
%o A053187 a053187 n = a053187_list !! n
%o A053187 a053187_list = 0 : concatMap (\x -> replicate (2*x) (x ^ 2)) [1..]
%o A053187 -- _Reinhard Zumkeller_, Nov 28 2011
%o A053187 (Python)
%o A053187 from math import isqrt
%o A053187 def A053187(n): return ((m:=isqrt(n))+int(n>m*(m+1)))**2 # _Chai Wah Wu_, Jun 06 2025
%Y A053187 Cf. A048760, A053188, A002483, A245552.
%Y A053187 Cf. A061023, A201053 (nearest cube), A000290, A000194.
%K A053187 easy,nonn
%O A053187 0,4
%A A053187 _Henry Bottomley_, Mar 01 2000
%E A053187 Title improved by _Jon E. Schoenfield_, Jun 09 2019