OFFSET
0,3
COMMENTS
LINKS
FORMULA
EXAMPLE
For n = 23,
- the binary representation of 23 is "10111",
- the corresponding run lengths are (1, 1, 3),
- so a(23) = 2^(1-1) + 2^(1+1-1) + 2^(1+1+3-1) = 19.
MATHEMATICA
a[n_] := If[n == 0, 0, 2^((Length /@ Split[IntegerDigits[n, 2]] // Accumulate)-1) // Total];
Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Jan 02 2022 *)
PROG
(PARI) a(n) = { my (v=0); while (n, my (w=valuation(n+n%2, 2)); n\=2^w; v=2^w*(1+v)); v/2 }
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist, Feb 23 2021
STATUS
approved