OFFSET
0,3
COMMENTS
Partial sums of number of runs in binary expansion of n (n>0). Partial sums of number of 1's in Gray code for n. The subsequence of squares in this partial sum begins 0, 1, 4, 9, 144, 169, 256, 289, 324 (since we also have 32 and 128 I wonder about why so many powers). The subsequence of primes in this partial sum begins: 3, 11, 17, 29, 31, 37, 41, 53, 79, 89, 101, 137, 149, 181, 191, 197, 229, 271.
Note: A227744 now gives the squares, which occur at positions given by A227743. - Antti Karttunen, Jul 27 2013
LINKS
Antti Karttunen, Table of n, a(n) for n = 0..8191
Richard Blecksmith and Purushottam W. Laud, Some Exact Number Theory Computations via Probability Mechanisms, American Mathematical Monthly, volume 102, number 10, December 1995, pages 893-903, with a(n) = Sum_{j=0..n} b_j as calculated in section 2.
Hsien-Kuei Hwang, Svante Janson and Tsung-Hsi Tsai, Exact and Asymptotic Solutions of a Divide-and-Conquer Recurrence Dividing at Half: Theory and Applications, ACM Transactions on Algorithms, volume 13, number 4, December 2017, article number 47, pages 1-43. Also first authors' copy, 2016. See example 5.5.
Kevin Ryde, Iterations of the Dragon Curve, see index "DirCumul".
FORMULA
a(2n) = 2*a(n) + n - 2*(ceiling(A005811(n)/2) - (n mod 2)), a(2n+1) = 2*a(n) + n + 1. - Ralf Stephan, Aug 11 2013
EXAMPLE
1 has 1 run in its binary representation "1".
2 has 2 runs in its binary representation "10".
3 has 1 run in its binary representation "11".
4 has 2 runs in its binary representation "100".
5 has 3 runs in its binary representation "101".
Thus a(1) = 1, a(2) = 1+2 = 3, a(3) = 1+2+1 = 4, a(4) = 1+2+1+2 = 6, a(5) = 1+2+1+2+3 = 9.
MATHEMATICA
Accumulate[Join[{0}, Table[Length[Split[IntegerDigits[n, 2]]], {n, 110}]]] (* Harvey P. Dale, Jul 29 2013 *)
PROG
(PARI) a(n) = my(v=binary(n+1), d=0, e=4); for(i=1, #v, if(v[i], v[i]=#v-i+d; d+=e; e=0, e=4)); fromdigits(v, 2)>>1; \\ Kevin Ryde, Aug 27 2021
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Jonathan Vos Post, Feb 16 2010
STATUS
approved