login
A371535
In the decimal representation of n, retain the k-th decimal digit if the k-th binary digit in n is 1.
0
1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 12, 13, 14, 15, 1, 1, 1, 1, 2, 2, 2, 2, 24, 25, 26, 27, 28, 29, 30, 31, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8
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
Cf. A007088.
Sequence in context: A326652 A222493 A032762 * A180410 A071650 A037265
KEYWORD
nonn,base
AUTHOR
STATUS
approved