OFFSET
0,3
LINKS
Paolo Xausa, Table of n, a(n) for n = 0..1000
Félix Balado and Guénolé C. M. Silvestre, Systematic Enumeration of Fundamental Quantities Involving Runs in Binary Strings, arXiv:2602.10005 [math.CO], 2026. See p. 100, Sect. 8.1.
Index entries for linear recurrences with constant coefficients, signature (4,-4).
FORMULA
For n>=4, a(n) = (3+7*(n+1))*2^(n-5); for n<4, a(n) = (n+1)*2^(n-2).
G.f.: x*(x^2+x+1)*(x-1)^2/(2*x-1)^2. - Alois P. Heinz, Aug 14 2025
EXAMPLE
For n=3, the breakdown of the 8 runs of 1s is as follows: 001 (1), 010 (1), 011 (1), 100 (1), 101 (2), 110 (1) and 111 (1).
For n=4, the breakdown of the 19 runs of 1s is as follows: 0001 (1), 0010 (1), 0011 (1), 0100 (1), 0101 (2), 0110 (1), 0111 (1), 1000 (1), 1001 (2), 1010 (2), 1011 (2), 1100 (1), 1101 (2) and 1110 (1).
MATHEMATICA
LinearRecurrence[{4, -4}, {0, 1, 3, 8, 19, 45}, 40] (* Paolo Xausa, Aug 19 2025 *)
PROG
(Python)
def A386878(n): return (0, 1, 3, 8, 19)[n] if n<5 else 3+7*(n+1)<<n-5 # Chai Wah Wu, Aug 19 2025
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Félix Balado, Aug 06 2025
STATUS
approved
