login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A007633 Palindromic in bases 3 and 10.
(Formerly M1164)
41

%I M1164 #58 Oct 30 2023 00:47:45

%S 0,1,2,4,8,121,151,212,242,484,656,757,29092,48884,74647,75457,76267,

%T 92929,93739,848848,1521251,2985892,4022204,4219124,4251524,4287824,

%U 5737375,7875787,7949497,27711772,83155138,112969211,123464321

%N Palindromic in bases 3 and 10.

%D J. Meeus, Multibasic palindromes, J. Rec. Math., 18 (No. 3, 1985-1986), 168-173.

%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

%H Patrick De Geest, <a href="/A007633/b007633.txt">Table of n, a(n) for n = 1..65</a> (terms 1..41 from Robert Israel, terms 42..63 from Robert G. Wilson v)

%H M. R. Calandra, <a href="/A007632/a007632.pdf">Integers which are palindromic in both decimal and binary notation</a>, J. Rec. Math., 18 (No. 1, 1985-1986), 47. (Annotated scanned copy) [With scan of J. Rec. Math. 18.3 (1985), pp. 168-173]

%H Patrick De Geest, <a href="http://www.worldofnumbers.com/nobase10.htm#base2to9">Palindromic numbers in other bases</a>.

%p ND:= 12; # to get all terms with <= ND decimal digits

%p rev10:= proc(n) option remember;

%p rev10(floor(n/10)) + (n mod 10)*10^ilog10(n)

%p end;

%p for i from 0 to 9 do rev10(i):= i od:

%p rev3:= proc(n) option remember;

%p rev3(floor(n/3)) + (n mod 3)*3^ilog[3](n)

%p end;

%p for i from 0 to 2 do rev3(i):= i od:

%p pali3:= n -> rev3(n) = n;

%p count:= 1:

%p A[1]:= 0:

%p for d from 1 to ND do

%p d1:= ceil(d/2);

%p for x from 10^(d1-1) to 10^d1 - 1 do

%p if d::even then y:= x*10^d1+rev10(x)

%p else y:= x*10^(d1-1)+rev10(floor(x/10));

%p fi;

%p if pali3(y) then

%p count:= count+1;

%p A[count]:= y;

%p fi

%p od:

%p od:

%p seq(A[i],i=1..count); # _Robert Israel_, Apr 20 2014

%t Do[ a = IntegerDigits[n]; b = IntegerDigits[n, 3]; If[a == Reverse[a] && b == Reverse[b], Print[n] ], {n, 0, 10^9} ]

%t 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 *)

%t 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 *)

%t Select[Range[0, 10^5],

%t PalindromeQ[#] && # == IntegerReverse[#, 3] &] (* _Robert Price_, Nov 09 2019 *)

%o (Python)

%o from itertools import chain

%o from gmpy2 import digits

%o 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

%Y Cf. A007632, A029961, A029962, A029963, A029964, A029804, A029965, A029966, A029967, A029968, A029969, A029970, A029731, A097855, A099165.

%K nonn,base

%O 1,3

%A _N. J. A. Sloane_, _Mira Bernstein_, _Robert G. Wilson v_

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 04:14 EDT 2024. Contains 371918 sequences. (Running on oeis4.)