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.
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
Examples
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.
Links
Programs
-
PARI
a(n) = { my (v=0); while (n, my (r=valuation(n+(n%2),2)); v+=r^2; n\=2^r); v }
Comments