cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A386878 Number of runs of 1's of length <= 3 over all binary strings of length n.

This page as a plain text file.
%I A386878 #25 Aug 19 2025 08:42:23
%S A386878 0,1,3,8,19,45,104,236,528,1168,2560,5568,12032,25856,55296,117760,
%T A386878 249856,528384,1114112,2342912,4915200,10289152,21495808,44826624,
%U A386878 93323264,193986560,402653184,834666496,1728053248,3573547008,7381975040,15233712128,31406948352
%N A386878 Number of runs of 1's of length <= 3 over all binary strings of length n.
%H A386878 Paolo Xausa, <a href="/A386878/b386878.txt">Table of n, a(n) for n = 0..1000</a>
%H A386878 <a href="/index/Rec#order_02">Index entries for linear recurrences with constant coefficients</a>, signature (4,-4).
%F A386878 For n>=4, a(n)=(3+7*(n+1))*2^(n-5); for n<4, a(n)=(n+1)*2^(n-2).
%F A386878 G.f.: x*(x^2+x+1)*(x-1)^2/(2*x-1)^2. - _Alois P. Heinz_, Aug 14 2025
%e A386878 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).
%e A386878 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).
%t A386878 LinearRecurrence[{4, -4}, {0, 1, 3, 8, 19, 45}, 40] (* _Paolo Xausa_, Aug 19 2025 *)
%o A386878 (Python)
%o A386878 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
%Y A386878 Cf. A045623, A106472, A001792.
%K A386878 nonn,easy
%O A386878 0,3
%A A386878 _Félix Balado_, Aug 06 2025