Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #18 Sep 08 2022 08:46:01
%S 0,0,0,0,2,7,19,46,107,242,535,1162,2490,5281,11108,23206,48206,99663,
%T 205218,421115,861585,1758249,3580075,7275377,14759592,29897683,
%U 60481359,122206014,246665382,497414751,1002231335,2017877779,4060069150,8164204342
%N Number of subsets of {1,...,n} containing a subset of the form {k,k+1,k+3} for some k.
%C Also, number of subsets of {1,...,n} containing {a,a+2,a+3} for some a.
%C Also, number of bitstrings of length n containing 1101 or 1111.
%H David Nacin, <a href="/A209400/b209400.txt">Table of n, a(n) for n = 0..500</a>
%H <a href="/index/Rec#order_06">Index entries for linear recurrences with constant coefficients</a>, signature (3,-1,-2,1,-1,-2).
%F a(n) = 3*a(n-1) - a(n-2) - 2*a(n-3) + a(n-4) - a(n-5) - 2*a(n-6), a(4)=2, a(5)=7, a(i)=0 for i<4.
%F G.f.: x^4*(2 + x)/(1 - 3*x + x^2 + 2*x^3 - x^4 + x^5 + 2*x^6) = x^4*(2 + x)/((1 - 2*x)*(1 - x - x^2 - x^4 - x^5)).
%F a(n) = 2^n - A164387(n).
%e When n=4 the only subsets containing an {a,a+1,a+3} happen when a=1 with the two subsets {1,2,3,4} and {1,2,4}. Thus a(4)=2.
%t LinearRecurrence[{3, -1, -2, 1, -1, -2}, {0, 0, 0, 0, 2, 7}, 40]
%t CoefficientList[Series[x^4*(2+x)/(1-3*x+x^2+2*x^3-x^4+x^5+2*x^6), {x,0, 50}], x] (* _G. C. Greubel_, Jan 03 2018 *)
%o (Python)
%o #From recurrence
%o def a(n, adict={0:0, 1:0, 2:0, 3:0, 4:2, 5:7}):
%o .if n in adict:
%o ..return adict[n]
%o .adict[n]=3*a(n-1)-a(n-2)-2*a(n-3)+a(n-4)-a(n-5)-2*a(n-6)
%o .return adict[n]
%o (Python)
%o #Returns the actual list of valid subsets
%o def contains1101(n):
%o .patterns=list()
%o .for start in range (1,n-2):
%o ..s=set()
%o ..for i in range(4):
%o ...if (1,1,0,1)[i]:
%o ....s.add(start+i)
%o ..patterns.append(s)
%o .s=list()
%o .for i in range(2,n+1):
%o ..for temptuple in comb(range(1,n+1),i):
%o ...tempset=set(temptuple)
%o ...for sub in patterns:
%o ....if sub <= tempset:
%o .....s.append(tempset)
%o .....break
%o .return s
%o #Counts all such sets
%o def countcontains1101(n):
%o .return len(contains1101(n))
%o (PARI) x='x+O('x^30); concat([0,0,0,0], Vec(x^4*(2+x)/(1-3*x+x^2+2*x^3-x^4+x^5+2*x^6))) \\ _G. C. Greubel_, Jan 03 2018
%o (Magma) I:=[0, 0, 0, 0, 2, 7]; [n le 6 select I[n] else 3*Self(n-1) - Self(n-2)-2*Self(n-3)+Self(n-4)-Self(n-5)-2*Self(n-6): n in [0..30]]; //
%o _G. C. Greubel_, Jan 03 2018
%Y Cf. A209398, A209399, A164387
%K nonn,easy
%O 0,5
%A _David Nacin_, Mar 07 2012