login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A057148
Palindromes only using 0 and 1 (i.e., base-2 palindromes).
31
0, 1, 11, 101, 111, 1001, 1111, 10001, 10101, 11011, 11111, 100001, 101101, 110011, 111111, 1000001, 1001001, 1010101, 1011101, 1100011, 1101011, 1110111, 1111111, 10000001, 10011001, 10100101, 10111101, 11000011, 11011011, 11100111, 11111111, 100000001
OFFSET
1,3
COMMENTS
For each term having fewer than 10 digits, the square will also be a palindrome. - Dmitry Kamenetsky, Oct 21 2008
LINKS
MATHEMATICA
(* get NextPalindrome from A029965 *)
Select[ NestList[ NextPalindrome, 0, 11110], Max(AT) IntegerDigits(AT)# < 2 &] (* Robert G. Wilson v *)
Select[FromDigits/@Tuples[{0, 1}, 8], IntegerDigits[#]==Reverse[ IntegerDigits[ #]]&] (* Harvey P. Dale, Apr 20 2015 *)
PROG
(Sage)
[int(n.binary()) for n in (0..220) if Word(n.digits(2)).is_palindrome()] # Peter Luschny, Sep 13 2018
(Python)
from itertools import count, islice, product
def agen(): # generator of terms
yield from [0, 1]
for d in count(2):
for rest in product("01", repeat=d//2-1):
left = "1" + "".join(rest)
for mid in [[""], ["0", "1"]][d%2]:
yield int(left + mid + left[::-1])
print(list(islice(agen(), 32))) # Michael S. Branicky, Mar 29 2022
(Python)
def A057148(n):
if n == 1: return 0
a = 1<<n.bit_length()-2
s = bin(a|(n&a-1))[2:]
return int(s+(s[::-1] if a&n else s[-2::-1])) # Chai Wah Wu, Jun 10 2024
CROSSREFS
Cf. A006995 for sequence translated from binary to decimal. A016116 for number of terms of sequence with n+1 binary digits (0 taken to have no digits).
Sequence in context: A263609 A333415 A264406 * A076289 A350346 A247647
KEYWORD
base,nonn
AUTHOR
Henry Bottomley, Aug 14 2000
STATUS
approved