OFFSET
0,3
COMMENTS
LINKS
FORMULA
EXAMPLE
For n = 49:
- the binary representation of 49 is "110001",
- we have a run of 2 1's followed by a run of 3 0's followed by a run of 1 1's,
- so a(49) = 2^2 + 3^2 + 1^2 = 14.
PROG
(PARI) a(n) = { my (v=0); while (n, my (r=valuation(n+(n%2), 2)); v+=r^2; n\=2^r); v }
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist, Feb 04 2020
STATUS
approved