login
A361479
a(n) is the least integer whose binary expansion has the same multiset of run-lengths as that of n.
3
0, 1, 2, 3, 4, 5, 4, 7, 8, 9, 10, 9, 12, 9, 8, 15, 16, 17, 18, 19, 18, 21, 18, 17, 24, 19, 18, 19, 24, 17, 16, 31, 32, 33, 34, 35, 36, 37, 36, 35, 34, 37, 42, 37, 36, 37, 34, 33, 48, 35, 36, 51, 36, 37, 36, 35, 56, 35, 34, 35, 48, 33, 32, 63, 64, 65, 66, 67
OFFSET
0,3
FORMULA
a(a(n)) = a(n).
a(n) <= n with equality iff n = 0 or belongs to A175020.
PROG
(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[h++], r[t--])-k%2; ); return (v); }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Mar 13 2023
STATUS
approved