cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A057148 Palindromes only using 0 and 1 (i.e., base-2 palindromes).

This page as a plain text file.
%I A057148 #42 Jun 11 2024 01:41:19
%S A057148 0,1,11,101,111,1001,1111,10001,10101,11011,11111,100001,101101,
%T A057148 110011,111111,1000001,1001001,1010101,1011101,1100011,1101011,
%U A057148 1110111,1111111,10000001,10011001,10100101,10111101,11000011,11011011,11100111,11111111,100000001
%N A057148 Palindromes only using 0 and 1 (i.e., base-2 palindromes).
%C A057148 For each term having fewer than 10 digits, the square will also be a palindrome. - _Dmitry Kamenetsky_, Oct 21 2008
%H A057148 Ray Chandler, <a href="/A057148/b057148.txt">Table of n, a(n) for n = 1..10000</a>
%t A057148 (* get NextPalindrome from A029965 *)
%t A057148 Select[ NestList[ NextPalindrome, 0, 11110], Max(AT) IntegerDigits(AT)# < 2 &] (* _Robert G. Wilson v_ *)
%t A057148 Select[FromDigits/@Tuples[{0,1},8],IntegerDigits[#]==Reverse[ IntegerDigits[ #]]&] (* _Harvey P. Dale_, Apr 20 2015 *)
%o A057148 (Sage)
%o A057148 [int(n.binary()) for n in (0..220) if Word(n.digits(2)).is_palindrome()] # _Peter Luschny_, Sep 13 2018
%o A057148 (Python)
%o A057148 from itertools import count, islice, product
%o A057148 def agen(): # generator of terms
%o A057148     yield from [0, 1]
%o A057148     for d in count(2):
%o A057148         for rest in product("01", repeat=d//2-1):
%o A057148             left = "1" + "".join(rest)
%o A057148             for mid in [[""], ["0", "1"]][d%2]:
%o A057148                 yield int(left + mid + left[::-1])
%o A057148 print(list(islice(agen(), 32))) # _Michael S. Branicky_, Mar 29 2022
%o A057148 (Python)
%o A057148 def A057148(n):
%o A057148     if n == 1: return 0
%o A057148     a = 1<<n.bit_length()-2
%o A057148     s = bin(a|(n&a-1))[2:]
%o A057148     return int(s+(s[::-1] if a&n else s[-2::-1])) # _Chai Wah Wu_, Jun 10 2024
%Y A057148 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).
%Y A057148 Cf. A002113, A118594, A118595, A118596, A118597, A118598, A118599, A118600.
%K A057148 base,nonn
%O A057148 1,3
%A A057148 _Henry Bottomley_, Aug 14 2000