[go: up one dir, main page]

login
A332017
a(n) is the sum of the squares of the lengths of the runs of consecutive equal digits in the binary representation of n.
1
0, 1, 2, 4, 5, 3, 5, 9, 10, 6, 4, 6, 8, 6, 10, 16, 17, 11, 7, 9, 7, 5, 7, 11, 13, 9, 7, 9, 13, 11, 17, 25, 26, 18, 12, 14, 10, 8, 10, 14, 12, 8, 6, 8, 10, 8, 12, 18, 20, 14, 10, 12, 10, 8, 10, 14, 18, 14, 12, 14, 20, 18, 26, 36, 37, 27, 19, 21, 15, 13, 15, 19
OFFSET
0,3
COMMENTS
a(0) = 0 by convention.
Every nonnegative number k appears A006456(k) times in the sequence, the last occurrence being at index A000975(k).
FORMULA
a(n) = Sum_{k = 1..A005811(n)} A101211(n, k)^2.
a(A000975(k)) = k for any k >= 0.
a(2^k-1) = k^2 for any k >= 0.
a(2^k) = k^2+1 for any k >= 0.
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
nonn,look,base
AUTHOR
Rémy Sigrist, Feb 04 2020
STATUS
approved