A164387
Number of binary strings of length n with no substrings equal to 0000 or 0010.
Original entry on oeis.org
1, 2, 4, 8, 14, 25, 45, 82, 149, 270, 489, 886, 1606, 2911, 5276, 9562, 17330, 31409, 56926, 103173, 186991, 338903, 614229, 1113231, 2017624, 3656749, 6627505, 12011714, 21770074, 39456161, 71510489, 129605869, 234898146, 425730250, 771595046, 1398441654
Offset: 0
When n=5, the bitstrings containing 0000 or 0010 are 00000, 10000, 00001, 10010, 00010, 00100, 00101. Thus a(5) = 2^5 - 7. - _David Nacin_, Mar 07 2012
-
f:=proc(n) option remember;
if n <= 3 then 2^n elif n=4 then 14
else f(n-1)+f(n-2)+f(n-4)+f(n-5); fi; end;
-
LinearRecurrence[{1, 1, 0, 1, 1}, {1, 2, 4, 8, 14}, 40] (* David Nacin, Mar 07 2012 *)
-
v=[1,2,4,8,14];while(#v<=1000,v=concat(v,v[#v]+v[#v-1]+v[#v-3]+v[#v-4]));v \\ Charles R Greathouse IV, Aug 01 2011
-
def a(n, adict={0:1, 1:2, 2:4, 3:8, 4:14}):
if n in adict:
return adict[n]
adict[n]=a(n-1)+a(n-2)+a(n-4)+a(n-5)
return adict[n] # David Nacin, Mar 07 2012
A209398
Number of subsets of {1,...,n} containing two elements whose difference is 2.
Original entry on oeis.org
0, 0, 0, 2, 7, 17, 39, 88, 192, 408, 855, 1775, 3655, 7478, 15228, 30898, 62511, 126177, 254223, 511472, 1027840, 2063600, 4140015, 8300767, 16635087, 33324462, 66736764, 133615658, 267461287, 535294673, 1071191415, 2143357000, 4288290240, 8579130888
Offset: 0
For n=3 the subsets containing 1 and 3 are {1,3} and {1,2,3} so a(3)=2.
-
[2^n - Fibonacci(Floor(n/2) + 2)*Fibonacci(Floor((n + 1)/2) + 2): n in [0..30]]; // G. C. Greubel, Jan 03 2018
-
Table[2^n -Fibonacci[Floor[n/2] + 2]*Fibonacci[Floor[(n + 1)/2] + 2], {n, 0,30}]
LinearRecurrence[{3, -2, 1, -1, -2}, {0, 0, 0, 2, 7}, 40]
CoefficientList[ Series[x^3 (x +2)/(2x^5 +x^4 -x^3 +2x^2 -3x +1), {x, 0, 33}], x] (* Robert G. Wilson v, Jan 03 2018 *)
a[n_] := Floor[ N[(2^-n ((50 - 14 Sqrt[5]) (1 - Sqrt[5])^n + ((-1 + 2I) (-2I)^n - (1 + 2I) (2I)^n + 5 4^n) (15 + 11 Sqrt[5]) - 2 (1 + Sqrt[5])^n (85 + 37 Sqrt[5])))/(150 + 110 Sqrt[5])]]; Array[a, 33] (* Robert G. Wilson v, Jan 03 2018 *)
-
x='x+O('x^30); concat([0,0,0], Vec(x^3*(2+x)/((1-2*x)*(1+x^2)*(1-x-x^2)))) \\ G. C. Greubel, Jan 03 2018
-
#Through Recurrence
def a(n, adict={0:0, 1:0, 2:0, 3:2, 4:7}):
if n in adict:
return adict[n]
adict[n]=3*a(n-1)-2*a(n-2)+a(n-3)-a(n-4)-2*a(n-5)
return adict[n]
-
#Returns the actual list of valid subsets
def contains101(n):
patterns=list()
for start in range (1,n-1):
s=set()
for i in range(3):
if (1,0,1)[i]:
s.add(start+i)
patterns.append(s)
s=list()
for i in range(2,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 subsets using the preceding function
def countcontains101(n):
return len(contains101(n))
A209399
Number of subsets of {1,...,n} containing two elements whose difference is 3.
Original entry on oeis.org
0, 0, 0, 0, 4, 14, 37, 83, 181, 387, 824, 1728, 3584, 7360, 15032, 30571, 61987, 125339, 252883, 509294, 1024300, 2057848, 4130724, 8285758, 16610841, 33285207, 66673209, 133512759, 267294832, 535025408, 1070755840, 2142652160, 4287149680, 8577285255
Offset: 0
When n=4 any such subset must contain 1 and 4. There are four such subsets so a(4) = 4.
- David Nacin, Table of n, a(n) for n = 0..500
- Index entries for linear recurrences with constant coefficients, signature (3,-1,-3,3,-1,-1,-3,1,2).
-
[2^n - Fibonacci(Floor(n/3) + 2)*Fibonacci(Floor((n + 1)/3) + 2)*Fibonacci(Floor((n + 2)/3) + 2): n in [0..30]]; // G. C. Greubel, Jan 03 2018
-
LinearRecurrence[{3, -1, -3, 3, -1, -1, -3, 1, 2}, {0, 0, 0, 0, 4, 14, 37, 83, 181}, 50]
Table[2^n - Product[Fibonacci[Floor[(n + i)/3] + 2], {i, 0, 2}], {n, 0, 50}]
-
x='x+O('x^30); concat([0,0,0,0], Vec(x^4*(4+2*x-x^2-2*x^3-x^4)/( (1-2*x)*(1-x-x^2)*(1+x^3-x^6)))) \\ G. C. Greubel, Jan 03 2018
-
#From recurrence
def a(n, adict={0:0, 1:0, 2:0, 3:0, 4:4, 5:14, 6:37, 7:83, 8:181}):
if n in adict:
return adict[n]
adict[n]=3*a(n-1)-a(n-2)-3*a(n-3)+3*a(n-4)-a(n-5)-a(n-6)-3*a(n-7)+a(n-8)+2*a(n-9)
return adict[n]
-
#Returns the actual list of valid subsets
def contains1001(n):
patterns=list()
for start in range (1,n-2):
s=set()
for i in range(4):
if (1,0,0,1)[i]:
s.add(start+i)
patterns.append(s)
s=list()
for i in range(2,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 countcontains1001(n):
return len(contains1001(n))
Showing 1-3 of 3 results.
Comments