login
A352450
2^k appears in the binary expansion of a(n) iff 2^k appears in the binary expansion of n and k AND n > 0 (where AND denotes the bitwise AND operator).
5
0, 0, 0, 2, 0, 0, 4, 6, 0, 8, 8, 10, 0, 8, 12, 14, 0, 0, 0, 2, 16, 16, 20, 22, 0, 8, 8, 10, 16, 24, 28, 30, 0, 32, 0, 34, 32, 32, 36, 38, 0, 40, 8, 42, 32, 40, 44, 46, 0, 32, 0, 34, 48, 48, 52, 54, 0, 40, 8, 42, 48, 56, 60, 62, 0, 0, 64, 66, 64, 64, 68, 70, 0
OFFSET
0,4
COMMENTS
The idea is to keep the 1's in the binary expansion of a number whose positions are related in some way to that number.
FORMULA
a(n) <= n with equality iff n = 0.
EXAMPLE
For n = 42:
- 42 = 2^5 + 2^3 + 2^1,
- 42 AND 5 = 0,
- 42 AND 3 = 2 > 0,
- 42 AND 1 = 0,
- so a(42) = 2^3 = 8.
PROG
(PARI) a(n) = { my (v=0, m=n, k); while (m, m-=2^k=valuation(m, 2); if (bitand(n, k), v+=2^k)); v }
CROSSREFS
See A352449, A352451, A352452, A352458 for similar sequences.
Sequence in context: A282551 A333706 A056676 * A098699 A021837 A236934
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Mar 16 2022
STATUS
approved