login
A050426
Numbers for which in base 2 the least number of digits that can be removed to leave a base 2 palindromic number (beginning with 1) is 2.
4
4, 12, 20, 22, 26, 28, 36, 38, 39, 46, 50, 57, 58, 60, 68, 70, 71, 74, 75, 79, 82, 84, 86, 87, 94, 98, 105, 106, 108, 110, 113, 117, 118, 121, 122, 124, 132, 134, 135, 138, 139, 141, 154, 155, 159, 162, 166, 167, 175, 177, 178, 179, 180, 182, 190, 194, 202
OFFSET
1,1
EXAMPLE
(70 base 2) = 1000110 -> 10001.
PROG
(Python)
from itertools import combinations
def ok(n):
b = bin(n)[2:]
for digs_to_remove in range(4):
for skip in combinations(range(len(b)), digs_to_remove):
newb = "".join(b[i] for i in range(len(b)) if i not in skip)
if len(newb) > 0 and newb[0] == '1' and newb == newb[::-1]:
return (digs_to_remove == 2)
return False
print(list(filter(ok, range(203)))) # Michael S. Branicky, Aug 24 2021
CROSSREFS
KEYWORD
nonn,base
STATUS
approved