OFFSET
0,6
COMMENTS
Also, the number of bitstrings of length n containing 10101,11101,10111 or 11111.
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (3,-2,2,-4,2,-2,-4,-1,1,2).
FORMULA
A(n) = 2^n - A209410(n)
a(n) = 2^n - t[floor(n/2)+2]*t[floor((n+1)/2)+2] where t(n) is the n-th tribonacci number.
a(n) = 3*a(n-1) - 2*a(n-2) + 2*a(n-3) - 4*a(n-4) + 2*a(n-5) - 2*a(n-6) - 4*a(n-7) - a(n-8) + a(n-9) + 2*a(n-10).
G.f.: x^5*(4 + 3*x - 2*x^3 - x^4)/((1 - 2*x) (1 - x - x^2 - x^3) (1 + x^2 + x^4 - x^6)).
EXAMPLE
For n=5, subsets containing {a,a+2,a+4} occur only when a=1. There are 2^2 subsets including {1,3,5}, thus a(5) = 4.
MATHEMATICA
LinearRecurrence[{3, -2, 2, -4, 2, -2, -4, -1, 1, 2}, {0, 0, 0, 0, 0, 4, 15, 37, 87, 200}, 40]
PROG
(Python)
#Returns the actual list of valid subsets
def containscode(n, bitstring=(1, 0, 1, 0, 1)):
.patterns=list()
.for start in range (1, n-len(bitstring)+2):
..s=set()
..for i in range(len(bitstring)):
...if bitstring[i]:
....s.add(start+i)
..patterns.append(s)
.s=list()
.for i in range(sum(bitstring), n+1):
..for temptuple in comb(range(1, n+1), i):
...tempset=set(temptuple)
...for sub in patterns:
....if sub <= tempset:
.....s.append(tempset)
.....break
.return s
#Counts all such sets
def countcontainscode(n, bitstring=(1, 0, 1, 0, 1)):
.return len(containscode(n))
(Python)
#From recurrence
def a(n, adict={0:0, 1:0, 2:0, 3:0, 4:0, 5:4, 6:15, 7:37, 8:87, 9:200}):
.if n in adict:
..return adict[n]
.adict[n]=3*a(n-1) - 2*a(n-2) + 2*a(n-3) - 4*a(n-4) + 2*a(n-5) - 2*a(n-6) - 4*a(n-7) - a(n-8) + a(n-9) + 2*a(n-10)
.return adict[n]
(PARI) x='x+O('x^30); concat([0, 0, 0, 0, 0], Vec(x^5*(4+3*x-2*x^3-x^4)/((1- 2*x)*(1-x-x^2-x^3)*(1+x^2+x^4-x^6)))) \\ G. C. Greubel, Jan 03 2018
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
David Nacin, Mar 08 2012
STATUS
approved