login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

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

%I #11 Mar 20 2022 18:29:59

%S 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,

%T 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,

%U 52,54,0,40,8,42,48,56,60,62,0,0,64,66,64,64,68,70,0

%N 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).

%C 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.

%H Rémy Sigrist, <a href="/A352450/b352450.txt">Table of n, a(n) for n = 0..8192</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%F a(n) <= n with equality iff n = 0.

%e For n = 42:

%e - 42 = 2^5 + 2^3 + 2^1,

%e - 42 AND 5 = 0,

%e - 42 AND 3 = 2 > 0,

%e - 42 AND 1 = 0,

%e - so a(42) = 2^3 = 8.

%o (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 }

%Y See A352449, A352451, A352452, A352458 for similar sequences.

%K nonn,base

%O 0,4

%A _Rémy Sigrist_, Mar 16 2022