%I #50 Oct 01 2024 09:00:49
%S 0,0,0,0,1,4,12,32,79,186,424,944,2065,4456,9512,20128,42287,88310,
%T 183492,379624,782497,1607756,3294164,6732992,13732063,27953522,
%U 56807184,115269984,233585121,472771152,955843984,1930635712,3896121759,7856343278,15830584396
%N Number of binary strings of length n that contain the substring 1000.
%C a(n)=2^(n-3)+a(n-1)+a(n-2)+a(n-3)-1 for n>=7.
%C Proof: Copnsider possible endings of the sequence:
%C 1. If it ends with 000, then all sequences except 00...0 work, meaning that 2^(n-3)-1 sequences are valid.
%C 2. If it ends with 100, then there are a(n-3) valid sequences.
%C 3. If it ends with 10, then there are a(n-2) valid sequences.
%C 4. If it ends with 1, then there are a(n-1) valid sequences.
%C As these are the only possible endings, the conclusion holds.
%C If we search for a sequence 10...0 (with k zeros), an extended version of the same algorithm gives a(n)=a(n-k)+a(n-k-1)...+a(n-1)+2^(n-k)-1
%H Paolo Xausa, <a href="/A373046/b373046.txt">Table of n, a(n) for n = 0..1000</a>
%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (4,-4,0,-1,2).
%F a(n) = 2^(n-3) + a(n-1) + a(n-2) + a(n-3) - 1.
%F a(n) = 3*a(n-1) - a(n-2) - a(n-3) - 2*a(n-4) + 1.
%F G.f.: -x^4/((x-1)*(2*x-1)*(x^3+x^2+x-1)). - _Alois P. Heinz_, Aug 02 2024
%F 2*a(n) = 1+2^(n+1)-A000213(n+3). - _R. J. Mathar_, Aug 28 2024
%e a(5) = 4: 01000, 11000, 10000, 10001.
%t LinearRecurrence[{4, -4, 0, -1, 2}, {0, 0, 0, 0, 1}, 50] (* _Paolo Xausa_, Oct 01 2024 *)
%o (Python)
%o def aupton(terms):
%o a = [0, 0, 0]
%o for n in range(3, terms):
%o next_term = 2**(n-3) + a[n-1] + a[n-2] + a[n-3] - 1
%o a.append(next_term)
%o return a[:terms]
%o print(aupton(35))
%Y Cf. A050232, A232580.
%K nonn,easy
%O 0,6
%A _Deyan Bozhkov_, Aug 02 2024