OFFSET
1,2
COMMENTS
We use the first digits from the left side in the binary expansion of n as rules: The 1s show as which digits of n we should keep and the 0s which ones we should delete. We only use the first k digits of the binary representation where k is the number of decimal digits of n.
LINKS
Eric Angelini, A selection using binary digits, Personal blog, February 2024.
EXAMPLE
a(22) = 2 because the binary representation of 22 is {1,0,1,1,0} and we must keep the first digit of 22 but not the second.
a(160) = 10 because the binary representation of 160 is {1,0,1,0,0,0,0,0} and we must keep the first and the third digit of 160 but not the second.
a(6794) = 674 because the binary representation of 6794 is {1,1,0,1,0,1,0,0,0,1,0,1,0} and we must keep the first, the second and the fourth digit of 6794 but not the third.
a(6794) = 674 since the digits kept are
n = binary 1 1 0 1 0 1 0 0 0 1 0 1 0
n = decimal 6 7 9 4
keep 6 7 4
MATHEMATICA
Table[FromDigits@Pick[IntegerDigits@n, IntegerDigits[n, 2][[;; IntegerLength@n]] , 1], {n, 80}]
PROG
(Python)
def a(n):
b, s = bin(n)[2:], str(n)
return int("".join(d for i, d in enumerate(s) if b[i]=="1"))
print([a(n) for n in range(1, 81)]) # Michael S. Branicky, Mar 26 2024
(PARI) a(n) = my(d=digits(n), b=binary(n), list=List()); for (i=1, #d, if (b[i], listput(list, d[i]))); fromdigits(Vec(list)); \\ Michel Marcus, Mar 27 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Giorgos Kalogeropoulos and Eric Angelini, Mar 26 2024
STATUS
approved