%I M2406 #90 Sep 13 2022 13:05:04
%S 0,1,3,5,7,9,33,99,313,585,717,7447,9009,15351,32223,39993,53235,
%T 53835,73737,585585,1758571,1934391,1979791,3129213,5071705,5259525,
%U 5841485,13500531,719848917,910373019,939474939,1290880921,7451111547
%N Numbers that are palindromic in bases 2 and 10.
%C Charlton Harrison found a new record binary-decimal palindrome: 11000101111000010101010110100001110100000100000101110000101101010101000011110100011_2 = 7475703079870789703075747_10 on Dec 01 2001. The binary string contains 83 digits! Since then he has added twenty more terms. - _Robert G. Wilson v_, Jul 03 2006
%C Intersection of A002113 and A006995. - _Reinhard Zumkeller_, Jan 22 2012, Feb 07 2010
%D M. R. Calandra, Integers which are palindromic in both decimal and binary notation, J. Rec. Math., 18 (No. 1, 1985-1986), 47.
%D S. Pilpel, Some More Double Palindromic Integers, J. Rec. Math., 18 (1985), 174-176.
%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%H Eshed Shaham, <a href="/A007632/b007632.txt">Table of n, a(n) for n = 1..175</a> (Terms 1..147 variously by Robert G. Wilson v, Charlton Harrison, Ilya Nikulshin, Andrey Astrelin)
%H Attila Bérczes and Volker Ziegler, <a href="http://arxiv.org/abs/1403.0787">On Simultaneous Palindromes</a>, arXiv:1403.0787 [math.NT], 2014 (see p. 9).
%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">Palindromic numbers beyond base 10</a>
%H Charlton Harrison, <a href="http://bach.dynet.com/palin/">Binary/Decimal Palindromes</a>
%H Project Euler, <a href="https://projecteuler.net/problem=36">Problem 36: Double-base palindromes</a>
%H Eshed Shaham, <a href="https://ashdnazg.github.io/articles/22/Finding-Really-Big-Palindromes">Finding Binary & Decimal Palindromes</a>
%p N:= 12: # to get all terms <= 10^N
%p ispal2:= proc(n) local L; if n::even then return false fi;
%p L:= convert(n,base,2); evalb(L=ListTools:-Reverse(L)) end proc:
%p rev10:= proc(n) local L; L:= convert(n,base,10); add(10^i*L[-i-1],i=0..nops(L)-1) end proc:
%p pals10:= proc(d) local x,y;
%p if d::even then [seq(x*10^(d/2)+rev10(x),x=10^(d/2-1)..10^(d/2)-1)]
%p else [seq(seq(x*10^((d+1)/2)+y*10^((d-1)/2)+rev10(x), y=0..9), x=10^((d-1)/2-1)..10^((d-1)/2)-1)]
%p fi
%p end proc:
%p 0, 1, 3, 5, 7, 9, seq(op(select(ispal2,pals10(d))),d=2..N); # _Robert Israel_, Dec 31 2015
%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, 2], AppendTo[l, a]], {n, 1000000}]; l (* _Robert G. Wilson v_, Sep 30 2004 *)
%t b1=2; b2=10; lst={}; Do[d1=IntegerDigits[n, b1]; d2=IntegerDigits[n, b2]; If[d1==Reverse[d1]&&d2==Reverse[d2], AppendTo[lst, n]], {n, 0, 2 10^7}]; lst (* _Vincenzo Librandi_, Dec 31 2015 *)
%t Select[Range[0,10^5], PalindromeQ[#] && # == IntegerReverse[#, 2] &] (* _Robert Price_, Nov 09 2019 *)
%o (Haskell)
%o a007632 n = a007632_list !! (n-1)
%o a007632_list = filter ((== 1) . a178225) a002113_list
%o -- _Reinhard Zumkeller_, Jan 22 2012
%o (Python)
%o from itertools import chain
%o A007632_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 bin(n)[2:] == bin(n)[:1:-1]]) # _Chai Wah Wu_, Nov 23 2014
%o (Magma) [n: n in [0..2*10^7] | Intseq(n, 10) eq Reverse(Intseq(n, 10))and Intseq(n, 2) eq Reverse(Intseq(n, 2))]; // _Vincenzo Librandi_, Dec 31 2015
%o (PARI) isok(n) = my(d = digits(n), b=binary(n)); (d == Vecrev(d)) && (b == Vecrev(b)); \\ _Michel Marcus_, Dec 31 2015
%Y For number of terms less than or equal to 10^n, see A120764.
%Y Cf. A007633, A029961, A029962, A029963, A029964, A029804, A029965, A029966, A029967, A029968, A029969, A029970, A029731, A097855, A099165.
%K base,nonn,nice
%O 1,3
%A _N. J. A. Sloane_, _Mira Bernstein_, _Robert G. Wilson v_
%E One more term from George Russell (ger(AT)tzi.de), Nov 20 2000
%E Two further terms from _Harvey P. Dale_, Mar 09 2001
%E Further terms from George Russell (ger(AT)tzi.de), Nov 02 2001
|