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.

A099165 Palindromic in bases 10 and 32.

This page as a plain text file.
%I A099165 #30 Mar 22 2020 17:19:19
%S A099165 0,1,2,3,4,5,6,7,8,9,11,22,33,66,99,363,858,1441,2882,5445,6886,9449,
%T A099165 15951,19891,21012,29692,32223,54945,369963,477774,564465,585585,
%U A099165 609906,672276,717717,780087,804408,912219,1251521,2639362,3825283
%N A099165 Palindromic in bases 10 and 32.
%H A099165 Ray Chandler and Robert G. Wilson v, <a href="/A099165/b099165.txt">Table of n, a(n) for n = 1..115</a>, terms a(88)-a(111) from Ray Chandler.
%t A099165 NextPalindrome[n_] := Block[{l = Floor[ Log[10, n] + 1], idn = IntegerDigits[n]}, If[ Union[idn] == {9}, Return[n + 2], If[l < 2, Return[n + 1], If[ FromDigits[ Reverse[ Take[idn, Ceiling[l/2]] ]] FromDigits[ Take[idn, -Ceiling[l/2]]], FromDigits[ Join[ Take[idn, Ceiling[l/2]], Reverse[ Take[idn, Floor[l/2]] ]]], idfhn = FromDigits[ Take[idn, Ceiling[l/2]]] + 1; idp = FromDigits[ Join[ IntegerDigits[idfhn], Drop[ Reverse[ IntegerDigits[idfhn]], Mod[l, 2]] ]]] ]]]; palQ[n_Integer, base_Integer] := Block[{idn = IntegerDigits[n, base]}, idn == Reverse[idn]]; l = {0}; a = 0; Do[a = NextPalindrome[a]; If[ palQ[a, 32], AppendTo[l, a]], {n, 10000}]; l
%t A099165 Select[Range[0, 10^5],
%t A099165 PalindromeQ[#] && # == IntegerReverse[#, 32] &] (* _Robert Price_, Nov 09 2019 *)
%o A099165 (Python)
%o A099165 from gmpy2 import digits
%o A099165 def palQ(n,b): # check if n is a palindrome in base b
%o A099165     s = digits(n,b)
%o A099165     return s == s[::-1]
%o A099165 def palQgen10(l): # unordered generator of palindromes of length <= 2*l
%o A099165     if l > 0:
%o A099165         yield 0
%o A099165         for x in range(1,10**l):
%o A099165             s = str(x)
%o A099165             yield int(s+s[-2::-1])
%o A099165             yield int(s+s[::-1])
%o A099165 A099165_list = sorted([n for n in palQgen10(6) if palQ(n,32)])
%o A099165 # _Chai Wah Wu_, Nov 25 2014
%Y A099165 Cf. A007632, A007633, A029961, A029962, A029963, A029964, A029804, A029965, A029966, A029967, A029968, A029969, A029970, A029731, A097855.
%K A099165 base,nonn
%O A099165 1,3
%A A099165 _Robert G. Wilson v_, Sep 30 2004