Recurrence relation with lists

36 Views Asked by At

In a certain exercise I am asked to find a recurrence for $a_n$, where $a_n$ is the number of $n$-lists of zeros and ones such that the sequence $111$ does not appear ($n \geq 1$). I have tried, but I obtained a recurrence which, at least for me, seems a bit weird. Here it is:
The set of those $n$-lists consists of those that start or with zero or with one. If it starts with zero, there are $a_{n-1}$ remaining lists that satisfy the condition. However, if it starts with one, then the second position can be either a one (therefore, the next position would need to be a zero and then one has to study $a_{n-3}$) or a zero. For the second case, then there are $a_{n-2}$ possibilities. Therefore, I obtain the recurrence $a_n = a_{n-1} + a_{n-2} + a_{n-3}$, and $a_1 = 2$ (there are two $1$-lists with zeros and ones), $a_2 = 4$ (there are four $2$-lists of zeros and ones), $a_3 = 8$ (all $3$-lists without $111$) and so on. Is this right ?