login
A102026
Number of n-bit strings that contain no more than 4 zeros and no more than 2 leading and 2 trailing zeros.
2
2, 4, 7, 13, 25, 49, 97, 191, 375, 737, 1449, 2849, 5601, 11011, 21647, 42557, 83665, 164481, 323361, 635711, 1249775, 2456993, 4830321, 9496161, 18668961, 36702211, 72154647, 141852301, 278874281, 548252401, 1077835841, 2118969471
OFFSET
1,1
COMMENTS
Used in the NRZ encoding to avoid substrings of more than 4 zeros.
REFERENCES
Raphael Reischuk, On avoiding monochrome substrings of length 5.
FORMULA
G.f.: 2*x+4*x^2 -x^3*(7+6*x+5*x^2+4*x^3+3*x^4) / ( -1+x+x^2+x^3+x^4+x^5 ). - R. J. Mathar, Oct 27 2012
EXAMPLE
a(3) = 2^3 - 1 = 7, since '000' is not a valid string, but all others are.
MATHEMATICA
m[x_] := If[x <= 4, 2^x,
If[x == 5, 31,
m[x - 1] + m[x - 2] + m[x - 3] + m[x - 4] + m[x - 5]]]
c[x_] := If[x <= 2, 0,
If[x == 3, 1,
If[x == 4, 3,
If[x == 5, 6,
If[x == 6, 12,
If[x == 7, 23,
If[x == 8, 45, 2*c[x - 1] - c[x - 6]]]]]]]]
valid[x_] := m[x] - c[x]
CROSSREFS
Sequence in context: A082423 A176485 A119266 * A103204 A326174 A366109
KEYWORD
nonn
AUTHOR
Raphael Reischuk (raphael(AT)stud.uni-saarland.de), Jun 18 2007
STATUS
approved