OFFSET

0,3

LINKS

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