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.

A047813 Largest palindromic substring of n.

This page as a plain text file.
%I A047813 #25 Sep 18 2022 19:45:54
%S A047813 0,1,2,3,4,5,6,7,8,9,1,11,2,3,4,5,6,7,8,9,2,2,22,3,4,5,6,7,8,9,3,3,3,
%T A047813 33,4,5,6,7,8,9,4,4,4,4,44,5,6,7,8,9,5,5,5,5,5,55,6,7,8,9,6,6,6,6,6,6,
%U A047813 66,7,8,9,7,7,7,7,7,7,7,77,8,9,8,8,8,8,8,8,8,8,88,9,9,9,9,9,9,9
%N A047813 Largest palindromic substring of n.
%C A047813 a(n) = A262188(n,A262190(n)-1). - _Reinhard Zumkeller_, Sep 14 2015
%H A047813 Reinhard Zumkeller, <a href="/A047813/b047813.txt">Table of n, a(n) for n = 0..10000</a>
%H A047813 <a href="/index/Pac#palindromes">Index entries for sequences related to palindromes</a>
%e A047813 a(1313) = Max{1,3,131,313} = 313.
%t A047813 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 *)
%t A047813 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 *)
%o A047813 (Haskell)
%o A047813 a047813 = last . a262188_row
%o A047813 -- _Reinhard Zumkeller_, Sep 14 2015, Aug 23 2011
%o A047813 (Python)
%o A047813 def c(s): return (s[0] != "0" or s == "0") and s == s[::-1]
%o A047813 def a(n):
%o A047813     s = str(n)
%o A047813     ss = (s[i:j] for i in range(len(s)) for j in range(i+1, len(s)+1))
%o A047813     return max(int(w) for w in ss if c(w))
%o A047813 print([a(n) for n in range(96)]) # _Michael S. Branicky_, Sep 18 2022
%Y A047813 Cf. A136522.
%Y A047813 Cf. A262188, A262223, A262224.
%K A047813 nonn,easy,base,nice,look
%O A047813 0,3
%A A047813 _N. J. A. Sloane_