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”).
%I #18 Mar 30 2023 15:28:38
%S 0,1,2,3,6,5,6,7,14,13,10,13,12,13,14,15,30,29,26,27,26,21,26,29,28,
%T 27,26,27,28,29,30,31,62,61,58,59,54,53,54,59,58,53,42,53,54,53,58,61,
%U 60,59,54,51,54,53,54,59,56,59,58,59,60,61,62,63,126,125
%N a(n) is the greatest integer whose binary expansion has the same multiset of run-lengths as that of n.
%H Rémy Sigrist, <a href="/A361480/b361480.txt">Table of n, a(n) for n = 0..8191</a>
%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F a(a(n)) = a(n).
%F a(n) >= n.
%o (PARI) a(n) = { my (r=[]); while (n, my (v=valuation(n+n%2, 2)); n\=2^v; r=concat(v, r)); r=vecsort(r); my (h=0, t=#r+1, v=0); for (k=1, #r, v=(v+k%2)*2^if (k%2, r[t--], r[h++])-k%2;); return (v); }
%Y Cf. A073138, A335835, A361478, A361479.
%K nonn,look,base
%O 0,3
%A _Rémy Sigrist_, Mar 13 2023