Suppose I flip a coin $n$ times. I want to calculate the number of all possible sequences of heads/tails such that I don't have two consecutive heads. For example, when $n = 3$, I have $5$ such sequences: $TTT$, $HTT$, $HTH$, $TTH$, $THT$.
My solution. We can have $k$ heads and $n-k$ tails, with $0 \leq k \leq n/2$ for $n$ even, and $0 \leq k \leq [n/2]+1$ if $n$ is odd.
Now for each $k$, there are $\frac{n!}{k!(n-k)!}$ ALL possible sequences (including consecutive heads).
At this point I am stuck - out of $\frac{n!}{k!(n-k)!}$ choices, how do I pick the ones that don't have two or more consecutive heads?
I would also appreciate it if you could point out a reference / general method for approaching such arrangement problems. This question is of my own device, so I don't know how easy or complicated the solution must be.
Here is an approach based upon generating functions. We start considering words with no consecutive equal letters at all.
These words are called Smirnov words or Carlitz words. (See example III.24 Smirnov words from Analytic Combinatorics by Philippe Flajolet and Robert Sedgewick for more information.)
A generating function for the number of Smirnov words over a two letter alphabet $\{H,T\}$ is given by \begin{align*} \left(1-\frac{2z}{1+z}\right)^{-1}\tag{1} \end{align*}
Recurrence relation:
From (3) we derive a recurrence relation of the coefficients $a_n$ of $A(z)=\sum_{n=0}^\infty a_nz^n$ from which we derive the wanted number $a_n, n\geq 0$.
At first we clear the denominator \begin{align*} A(z)&=\frac{1+z}{1-z-z^2}\\ \left(1-z-z^2\right)A(z)&=1+z\\ \left(1-z-z^2\right)(a_0+a_1z+a_2z^2+\cdots)&=1+z\tag{4}\\ \end{align*}
We get from the recurrence relation the numbers $(a_n)_{n\geq 0}=(1,2,3,5,8,13,21,\ldots)$ and see $a_n=F_{n+1}$, with $F_n$ the $n$-th Fibonacci Number.
In terms of the generating function $A(z)$ we have \begin{align*} A(z)=\frac{1+z}{1-z-z^2}=1+2z+3z^2+5z^3+8z^4+\color{blue}{13}z^5+21z^6+\cdots \end{align*}