Let $m, n$ be positive integers. Let $S(n,m)$ be the number of sequences of length $n$ and consisting of $0$ and $1$ in which there exists a $0$ in any consecutive $m$ digits. Find a formula for $S(n,m)$.
Let $P(n,m)$ denote the number of strings in which there exists at least one block of $m$ consecutive $1$'s. We have $S(n,m)=2^{n}-P(n,m)$.
Let $P_i(n,m)$ denote the number of strings in which there exists at least one block of $m$ consecutive $1$'s from left starting from the $(i+1)$'th position and ending in the $(i+m)$'th position, with no blocks of $m$ $1$'s starting before the $i+1$'th position. We shall have: $$P(n,m)=\sum_{i=0}^{n-m-1}{P_i(n,m)}$$
We shall first count $P_i(n,m)$. From the $1$'st position to the $i-1$'th position there are $S(i-1,m)$ ways to choose $1$'s and $0$'s. The $i$'th position must be $0$, and from the $i+1$'th to the $i+m$'th position, there must be $m$ number $1$'s. From the $i+m+1$'th position to the $n$'th position, we can choose either $1$ or $0$, there are $2^{n-m-i}$ ways to choose. Therefore: $$P_i(n,m)=2^{n-m-i}S(i-1,m)=2^{n-m-1}-2^{n-i-m}P(i-1,m)$$
Thus $$P(n,m)=(n-m+1)2^{n-m-1}-\sum_{i=0}^{n-m}{2^{n-m-i}P(i-1,m)}$$ with $P(-1,m)=1$.
Here I am stuck. How can I progress ? Or is there a better way to find a general formula for $S(n,m)$ ? Do such formula exist?
(Please let me know if this question should be closed. Sorry for my English grammar)
I don't think that there is an easy closed formula for $S(n,m)$, but it should satisfy the following linear recurrence for $n>m>0$ $$S(n,m)=\sum_{k=1}^m S(n-k,m).$$ because in the last part of the sequence we may have $0$, $01$, $011$, $\dots$, $0\underbrace{1\dots 1}_{m-1}$.
Moreover $S(n,1)=1$, $S(n,2)=F_{n+2}$ where $F_k$ is the $k$-th Fibonacci number, $S(n,3)=F^{(3)}_{n+3}$ where $F^{(3)}_{k}$ is the $k$-th Tribonacci number, $S(n,4)=F^{(4)}_{n+4}$ where $F^{(4)}_{k}$ is the $k$-th Tetranacci number,