OFFSET
0,3
COMMENTS
Leading 0's are not allowed, so a(103) = 9, not 060. - Robert Israel, Nov 05 2020
LINKS
Robert Israel, Table of n, a(n) for n = 0..10000
EXAMPLE
a(15) = largest palindromic substring of 15^2 = largest palindromic substring of 225 = 22.
MAPLE
g:= proc(S) S[1] <> "0" and S = StringTools:-Reverse(S) end proc:
f:= proc(n) local S, d, l, i, Q;
S:= sprintf("%d", n^2);
d:= length(S);
for l from d to 1 by -1 do
Q:= select(g, [seq(S[i..i+l-1], i=1..d+1-l)]);
if Q <> [] then return op(sscanf(max(Q), "%d")) fi
od;
end proc:
f(0):= 0:
map(f, [$0..200]); # Robert Israel, Nov 05 2020
CROSSREFS
KEYWORD
AUTHOR
Jonathan Vos Post, Mar 27 2011
STATUS
approved