OFFSET
0,3
COMMENTS
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
EXAMPLE
a(1313) = Max{1,3,131,313} = 313.
MATHEMATICA
palQ[n_Integer, base_Integer] := Module[{idn = IntegerDigits[n, base]}, idn == Reverse[ idn]]; f[n_] := Block[{id = IntegerDigits@ n, mx = -Infinity}, k = Length@ id; While[k > 0 && mx == -Infinity, mx = Max[mx, Select[ FromDigits@# & /@ Partition[id, k, 1], palQ[#, 10] &]]; k--]; mx] (* Robert G. Wilson v, Aug 24 2011 *)
lps[n_]:=Module[{idn=IntegerDigits[n]}, Max[FromDigits/@Select[ Flatten[ Table[ Partition[ idn, i, 1], {i, Length[idn]}], 1], #==Reverse[#]&]]]; Array[ lps, 100, 0] (* Harvey P. Dale, Jan 09 2015 *)
PROG
(Haskell)
a047813 = last . a262188_row
-- Reinhard Zumkeller, Sep 14 2015, Aug 23 2011
(Python)
def c(s): return (s[0] != "0" or s == "0") and s == s[::-1]
def a(n):
s = str(n)
ss = (s[i:j] for i in range(len(s)) for j in range(i+1, len(s)+1))
return max(int(w) for w in ss if c(w))
print([a(n) for n in range(96)]) # Michael S. Branicky, Sep 18 2022
CROSSREFS
KEYWORD
AUTHOR
STATUS
approved