%I #52 Jan 27 2024 17:19:05
%S 0,1,3,5,63,65,195,325,341,4095,4097,4161,12291,12483,20485,20805,
%T 21525,21845,258111,262143,262145,266305,786435,798915,1310725,
%U 1311749,1331525,1332549,1376277,1377301,1397077,1398101,16515135,16777215,16777217,16781313
%N Numbers that are palindromic in bases 2, 4, and 8.
%C Intersection of A006995, A014192, and A029803.
%C From _A.H.M. Smeets_, Jun 08 2019: (Start)
%C Intersection of A006995 and A259382.
%C Intersection of A014192 and A259380.
%C Intersection of A029803 and A097856.
%C All repunit numbers in base 2 with 6*k digits are included in this sequence, i.e., all terms A000225(6*k) for k >= 0.
%C All repunit numbers in base 4 with 2+3*k digits are included in this sequence, i.e., all terms A002450(2+3*k) for k >= 0.
%C All terms A000051(6*k) for k > 0 are included in this sequence.
%C All terms A052539(3*k) for k > 0 are included in this sequence.
%C In general, for sequences with palindromic numbers in the set of bases {b, b^2, ..., b^k}, gaps of size 2 occur at the term pairs (b^(k!) - 1, b^(k!) + 1). See also A319598 for b = 2 and k = 4.
%C The terms occur in bursts with large gaps in between as shown in the scatterplots of log_b(a(n)-a(n-1)) versus log_b(n) and log_b(1-a(n-1)/a(n)) versus log_b(n). Terms of this sequence are those with b = 2 and k = 3. For comparison, terms with b = 3 and k = 3 are also shown in these plots.
%C (End)
%H A.H.M. Smeets, <a href="/A319584/b319584.txt">Table of n, a(n) for n = 1..2298</a>
%H A.H.M. Smeets, <a href="/A319584/a319584.gif">Scatterplot of log_b(a(n)-a(n-1)) versus log_b(n)</a>
%H A.H.M. Smeets, <a href="/A319584/a319584_1.gif">Scatterplot of log_b(1-a(n-1)/a(n)) versus log_b(n)</a>
%e 89478485 = 101010101010101010101010101_2 = 11111111111111_4 = 525252525_8.
%t palQ[n_, b_] := PalindromeQ[IntegerDigits[n, b]];
%t Reap[Do[If[palQ[n, 2] && palQ[n, 4] && palQ[n, 8], Print[n]; Sow[n]], {n, 0, 10^6}]][[2, 1]] (* _Jean-François Alcover_, Sep 25 2018 *)
%t Select[Range[0,168*10^5],AllTrue[Table[IntegerDigits[#,d],{d,{2,4,8}}],PalindromeQ]&] (* _Harvey P. Dale_, Jan 27 2024 *)
%o (Sage) [n for n in (0..1000) if Word(n.digits(2)).is_palindrome() and Word(n.digits(4)).is_palindrome() and Word(n.digits(8)).is_palindrome()]
%o (Magma) [n: n in [0..2*10^7] | Intseq(n, 2) eq Reverse(Intseq(n, 2)) and Intseq(n, 4) eq Reverse(Intseq(n, 4)) and Intseq(n, 8) eq Reverse(Intseq(n, 8))]; // _Vincenzo Librandi_, Sep 24 2018
%o (Python)
%o def nextpal(n, base): # m is the first palindrome successor of n in base base
%o m, pl = n+1, 0
%o while m > 0:
%o m, pl = m//base, pl+1
%o if n+1 == base**pl:
%o pl = pl+1
%o n = n//(base**(pl//2))+1
%o m, n = n, n//(base**(pl%2))
%o while n > 0:
%o m, n = m*base+n%base, n//base
%o return m
%o def rev(n, b):
%o m = 0
%o while n > 0:
%o n, m = n//b, m*b+n%b
%o return m
%o n, a = 1, 0
%o while n <= 100:
%o if a == rev(a, 4) == rev(a, 2):
%o print(a)
%o n += 1
%o a = nextpal(a, 8) # _A.H.M. Smeets_, Jun 08 2019
%o (PARI) ispal(n, b) = my(d=digits(n, b)); Vecrev(d) == d;
%o isok(n) = ispal(n, 2) && ispal(n, 4) && ispal(n, 8); \\ _Michel Marcus_, Jun 11 2019
%Y Cf. A006995 (base 2), A014192 (base 4), A029803 (base 8), A097956 (bases 2 and 4), A259380 (bases 2 and 8), A259382 (bases 4 and 8), A319598 (bases 2, 4, 8 and 16).
%Y Cf. A000051, A000225, A002450, A052539.
%K nonn,base
%O 1,3
%A _Jeremias M. Gomes_, Sep 23 2018