%I #11 Mar 20 2022 18:29:38
%S 0,0,0,2,4,4,0,6,0,8,8,10,0,12,12,10,16,16,16,18,4,16,20,22,16,8,24,
%T 26,20,28,8,30,32,32,32,34,0,36,36,34,32,40,8,42,36,40,44,46,16,48,32,
%U 50,52,52,16,38,48,56,56,58,0,60,60,58,64,64,64,66,68,64
%N 2^k appears in the binary expansion of a(n) iff 2^k appears in the binary expansion of n and k+1 does not divide n.
%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="/A352452/b352452.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.
%e For n = 42:
%e - 42 = 2^5 + 2^3 + 2^1,
%e - 5+1 divides 42,
%e - 3+1 does not divide 42,
%e - 1+1 divides 42,
%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 (n%(k+1), v+=2^k)); v }
%Y See A352449, A352450, A352451, A352458 for similar sequences.
%K nonn,base
%O 0,4
%A _Rémy Sigrist_, Mar 16 2022