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.

A007633 Palindromic in bases 3 and 10.

Original entry on oeis.org

0, 1, 2, 4, 8, 121, 151, 212, 242, 484, 656, 757, 29092, 48884, 74647, 75457, 76267, 92929, 93739, 848848, 1521251, 2985892, 4022204, 4219124, 4251524, 4287824, 5737375, 7875787, 7949497, 27711772, 83155138, 112969211, 123464321
Offset: 1

Views

Author

Keywords

References

  • J. Meeus, Multibasic palindromes, J. Rec. Math., 18 (No. 3, 1985-1986), 168-173.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Maple
    ND:= 12;  # to get all terms with <= ND decimal digits
    rev10:= proc(n) option remember;
      rev10(floor(n/10)) + (n mod 10)*10^ilog10(n)
    end;
    for i from 0 to 9 do rev10(i):= i od:
    rev3:= proc(n) option remember;
      rev3(floor(n/3)) + (n mod 3)*3^ilog[3](n)
    end;
    for i from 0 to 2 do rev3(i):= i od:
    pali3:= n -> rev3(n) = n;
    count:= 1:
    A[1]:= 0:
    for d from 1 to ND do
      d1:= ceil(d/2);
      for x from 10^(d1-1) to 10^d1 - 1 do
        if d::even then y:= x*10^d1+rev10(x)
        else y:= x*10^(d1-1)+rev10(floor(x/10));
        fi;
        if pali3(y) then
           count:= count+1;
           A[count]:= y;
        fi
      od:
    od:
    seq(A[i],i=1..count); # Robert Israel, Apr 20 2014
  • Mathematica
    Do[ a = IntegerDigits[n]; b = IntegerDigits[n, 3]; If[a == Reverse[a] && b == Reverse[b], Print[n] ], {n, 0, 10^9} ]
    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, 4], AppendTo[l, a]], {n, 100000}]; l (* Robert G. Wilson v, Sep 30 2004 *)
    pal3Q[n_]:=Module[{idn3=IntegerDigits[n,3]},idn3==Reverse[idn3]]; Select[ Range[ 0,1235*10^5],PalindromeQ[#]&&pal3Q[#]&] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jan 04 2019 *)
    Select[Range[0, 10^5],
    PalindromeQ[#] && # == IntegerReverse[#, 3] &] (* Robert Price, Nov 09 2019 *)
  • Python
    from itertools import chain
    from gmpy2 import digits
    A007633_list = sorted([n for n in chain((int(str(x)+str(x)[::-1]) for x in range(1,10**6)),(int(str(x)+str(x)[-2::-1]) for x in range(10**6))) if digits(n,3) == digits(n,3)[::-1]]) # Chai Wah Wu, Nov 23 2014