login
Smallest square that contains the digits of n in its exact middle.
1

%I #13 Feb 17 2022 00:01:52

%S 0,1,121,12321,4,256,169,576,289,9,8100,2116,361201,3136,181476,1156,

%T 16,101761,5184,281961,2209,9216,1225,182329,3249,25,292681,192721,

%U 8281,1296,2304,183184,5329,343396,203401,4356,36,223729,173889,7396,2401

%N Smallest square that contains the digits of n in its exact middle.

%H Michael S. Branicky, <a href="/A062689/b062689.txt">Table of n, a(n) for n = 0..9999</a>

%e 8100 is the smallest square that contains 10 in its exact center.

%o (Python)

%o def centered(s, t):

%o q, r = divmod(len(t)-len(s), 2)

%o return r == 0 and t[q:].startswith(s)

%o def a(n):

%o k, target = 0, str(n)

%o while not centered(target, str(k**2)): k += 1

%o return k**2

%o print([a(n) for n in range(43)]) # _Michael S. Branicky_, Feb 16 2022

%Y Cf. A062690.

%K base,easy,nonn

%O 0,3

%A _Erich Friedman_, Jul 04 2001

%E Corrected and extended by _Harvey P. Dale_, Jul 21 2001

%E a(40) from _Bernard Schott_, Feb 16 2022