login
Nontrivial palindromes in base 10 and base 256.
3

%I #19 Sep 25 2021 14:59:43

%S 55255,63736,92929,96769,108801,450054,516615,995599,1413141,1432341,

%T 1539351,1558551,2019102,2491942,2807082,3097903,3740473,3866683,

%U 3885883,4201024,4220224,4327234,4346434,4365634,4384834,5614165,5633365,5759575,6692966,7153517,7172717

%N Nontrivial palindromes in base 10 and base 256.

%C Palindromes in base 256 are numbers that are the same in big-endian and little-endian order with 8-bit words. See also A238853.

%C A palindromic number in base 10 which is below 256 is a 1-digit number in base 256. Thus, it is automatically a palindrome in base 256. This sequence excludes 1-digit numbers in base 256. - _Tanya Khovanova_, Aug 21 2021

%H Chai Wah Wu, <a href="/A253148/b253148.txt">Table of n, a(n) for n = 1..121</a>

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Endianness">Endianness</a>

%e 7172717 in base 16 is 6d 72 6d and the bytes form a palindrome.

%t Select[Range[256, 10000000], PalindromeQ[#] && PalindromeQ[IntegerDigits[#, 256]] &] (* _Tanya Khovanova_, Aug 21 2021 *)

%o (Python)

%o from __future__ import division

%o def palgen(l, b=10): # generator of palindromes in base b of length <= 2*l

%o ....if l > 0:

%o ........yield 0

%o ........for x in range(1, l+1):

%o ............n = b**(x-1)

%o ............n2 = n*b

%o ............for y in range(n, n2):

%o ................k, m = y//b, 0

%o ................while k >= b:

%o ....................k, r = divmod(k, b)

%o ....................m = b*m + r

%o ................yield y*n + b*m + k

%o ............for y in range(n, n2):

%o ................k, m = y, 0

%o ................while k >= b:

%o ....................k, r = divmod(k, b)

%o ....................m = b*m + r

%o ................yield y*n2 + b*m + k

%o def reversedigits(n, b=10): # reverse digits of n in base b

%o ....x, y = n, 0

%o ....while x >= b:

%o ........x, r = divmod(x, b)

%o ........y = b*y + r

%o ....return b*y + x

%o A253148_list = []

%o for n in palgen(5):

%o ....if n > 255 and n == reversedigits(n,256):

%o ........A253148_list.append(n)

%Y Cf. A253147, A253149, A238853.

%K nonn,base

%O 1,1

%A _Chai Wah Wu_, Dec 30 2014

%E Name clarified by _Tanya Khovanova_, Aug 21 2021