Find probability adjacent components are not both of same type The question goes as follows:
There are n components lined up in a linear arrangement. Suppose that each component independently functions with probability p. What is the probability that no 2 neighboring components are both nonfunctional?
The way that I was trying to go about doing this was instead of counting the event specified, counting its complement. This would be the event that there is at least one pair of adjacent nonfunctioning components.
I tried brute forcing this to find a pattern, but unless I am counting incorrectly, I found none for n=2 (1/4), n=3 (3/8), n=4 (8/16), n=5 (14/32). The values in parenthesis indicate the probability of choosing a combination that contains adjacent nonfunctioning components. 
I also thought that this might be an application of the binomial theorem, but I couldn't figure out how to bring the need for components to be adjacent into that formulation of the probability.
Am I thinking about this incorrectly? Help would be appreciated.
 A: Suppose we have $n$ white balls and $n$ black balls. We need to choose $n$ from these and arrange them in a row such that no two black balls are consecutive. We discuss the cases on the number of black balls present. 
If there are no black balls, then all are white and there is only one way of arranging them. This corresponds to the case all machines function and has probability $p^n$. Suppose that we have one black ball. This can be in any of the $n+1$ positions between the $n-1$ white balls and hence there are $n+1$ ways of placing this defective machine. The probability is $(n+1)(1-p)p^{n-1}$.
For $k$ black balls, we will have $n-k$ white balls and we can choose $k$ out of the $n-k+1$ gaps between the whites and place these so that no two are consecutive. Thus the probability for this is $\binom{n-k+1}{k}p^{n-k}(1-p)^k$
Hence the required probability is 
$$\sum_{k=0}^n \binom{n-k+1}{k}p^{n-k}(1-p)^k $$
Note that the binomial term will be zero when $k > n-k+1$ or when $k > \frac{n+1}{2}$
A: One way to proceed is to find a recurrence for the probability.  Let's say a sequence of components is "acceptable" if no two adjacent components are nonfunctional.  Let $a_n$ be the probability of an acceptable sequence of length $n$.
If the first component is functional, which happens with probability $p$, then it may be followed by any acceptable sequence of length $n-1$.  If the first component is non-functional, with probability $1-p$, then the second component must be functional, with probability $p$, and must be followed by an acceptable sequence of length $n-2$.  So
$$a_n = p  a_{n-1} + (1-p)  p a_{n-2}$$ for $n > 2$, with $a_1= 1$ and $a_2 = 1-(1-p)^2$.  If we "work backwards" we find that if we set $a_0 = 1$ we can change the restriction on $n$ to $n \ge 2$, which simplifies things a little.
