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.

A248889 Palindromic in base 10 and 18.

This page as a plain text file.
%I A248889 #36 May 22 2025 10:21:41
%S A248889 0,1,2,3,4,5,6,7,8,9,11,171,323,343,505,595,686,848,1661,2112,3773,
%T A248889 23332,46664,69996,262262,583385,782287,859958,981189,1254521,1403041,
%U A248889 1832381,39388393,54411445,55499455,88844888,118919811,191010191
%N A248889 Palindromic in base 10 and 18.
%C A248889 a(54) > 10^12.
%H A248889 M. Fiorentini and Chai Wah Wu, <a href="/A248889/b248889.txt">Table of n, a(n) for n = 1..68</a> a(n) for n = 1..53 from M. Fiorentini.
%e A248889 848 in decimal is 2B2 in base 18, so 848 is in the sequence.
%e A248889 1661 in decimal is 525 in base 18, so 1661 is in the sequence.
%e A248889 1771 in decimal is 587 in base 18, which is not a palindrome, so 1771 is not in the sequence.
%p A248889 IsPalindromic := proc(n, Base)
%p A248889     local Conv, i;
%p A248889     Conv := convert(n, base, Base);
%p A248889     for i from 1 to nops(Conv) / 2 do
%p A248889         if Conv [i] <> Conv [nops(Conv) + 1 - i] then
%p A248889             return false;
%p A248889         fi:
%p A248889     od:
%p A248889     true;
%p A248889 end proc:
%p A248889 Base := 18;
%p A248889 A := [];
%p A248889 for i from 1 to 10^6 do:
%p A248889    S := convert(i, base, 10);
%p A248889    V := 0;
%p A248889    if i mod 10 = 0 then
%p A248889       next;
%p A248889    fi;
%p A248889    for j from 1 to nops(S) do:
%p A248889       V := V * 10 + S [j];
%p A248889    od:
%p A248889    for j from 0 to 10 do:
%p A248889       V1 := V * 10^(nops(S) + j) + i;
%p A248889       if IsPalindromic(V1, Base) then
%p A248889          A := [op(A), V1];
%p A248889       fi;
%p A248889    od:
%p A248889    V1 := (V - (V mod 10)) * 10^(nops(S) - 1) + i;
%p A248889    if IsPalindromic(V1, Base) then
%p A248889       A := [op(A), V1];
%p A248889    fi;
%p A248889 od:
%p A248889 sort(A);
%t A248889 palindromicQ[n_, b_:10] := TrueQ[IntegerDigits[n, b] == Reverse[IntegerDigits[n, b]]]; Select[Range[0, 499], palindromicQ[#] && palindromicQ[#, 18] &] (* _Alonso del Arte_, Mar 21 2015 *)
%o A248889 (PARI) isok(n) = (n==0) || ((d = digits(n, 10)) && (Vecrev(d) == d) && (d = digits(n, 18)) && (Vecrev(d) == d)); \\ _Michel Marcus_, Mar 14 2015
%o A248889 (Magma) [n: n in [0..2*10^7] | Intseq(n) eq Reverse(Intseq(n)) and Intseq(n,18) eq Reverse(Intseq(n,18))]; // _Vincenzo Librandi_, Mar 21 2015
%o A248889 (Python)
%o A248889 def palgen10(l): # generator of palindromes of length <= 2*l
%o A248889     if l > 0:
%o A248889         yield 0
%o A248889         for x in range(1,l+1):
%o A248889             n = 10**(x-1)
%o A248889             n2 = n*10
%o A248889             for y in range(n,n2):
%o A248889                 s = str(y)
%o A248889                 yield int(s+s[-2::-1])
%o A248889             for y in range(n,n2):
%o A248889                 s = str(y)
%o A248889                 yield int(s+s[::-1])
%o A248889 def palcheck(n, b): # check if n is a palindrome in base b
%o A248889     s = digits(n, b)
%o A248889     return s == s[::-1]
%o A248889 A248889_list = [n for n in palgen10(9) if palcheck(n, 18)]
%o A248889 # _Chai Wah Wu_, Mar 23 2015
%Y A248889 Cf. A007632, A007633, A029961, A029962, A029963, A029964, A029965, A029966, A029967, A029968, A029969, A029970, A028731, A097855, A248899
%K A248889 nonn,base
%O A248889 1,3
%A A248889 _Mauro Fiorentini_, Mar 05 2015