A319584 Numbers that are palindromic in bases 2, 4, and 8.
0, 1, 3, 5, 63, 65, 195, 325, 341, 4095, 4097, 4161, 12291, 12483, 20485, 20805, 21525, 21845, 258111, 262143, 262145, 266305, 786435, 798915, 1310725, 1311749, 1331525, 1332549, 1376277, 1377301, 1397077, 1398101, 16515135, 16777215, 16777217, 16781313
Offset: 1
Examples
89478485 = 101010101010101010101010101_2 = 11111111111111_4 = 525252525_8.
Links
- A.H.M. Smeets, Table of n, a(n) for n = 1..2298
- A.H.M. Smeets, Scatterplot of log_b(a(n)-a(n-1)) versus log_b(n)
- A.H.M. Smeets, Scatterplot of log_b(1-a(n-1)/a(n)) versus log_b(n)
Crossrefs
Programs
-
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
-
Mathematica
palQ[n_, b_] := PalindromeQ[IntegerDigits[n, b]]; 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 *) Select[Range[0,168*10^5],AllTrue[Table[IntegerDigits[#,d],{d,{2,4,8}}],PalindromeQ]&] (* Harvey P. Dale, Jan 27 2024 *)
-
PARI
ispal(n, b) = my(d=digits(n, b)); Vecrev(d) == d; isok(n) = ispal(n, 2) && ispal(n, 4) && ispal(n, 8); \\ Michel Marcus, Jun 11 2019
-
Python
def nextpal(n, base): # m is the first palindrome successor of n in base base m, pl = n+1, 0 while m > 0: m, pl = m//base, pl+1 if n+1 == base**pl: pl = pl+1 n = n//(base**(pl//2))+1 m, n = n, n//(base**(pl%2)) while n > 0: m, n = m*base+n%base, n//base return m def rev(n, b): m = 0 while n > 0: n, m = n//b, m*b+n%b return m n, a = 1, 0 while n <= 100: if a == rev(a, 4) == rev(a, 2): print(a) n += 1 a = nextpal(a, 8) # A.H.M. Smeets, Jun 08 2019
-
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()]
Comments