124. Recurrence relations in counting
Many counting formulas can be derived as recurrence relations. In many cases, you can then find a closed formula which evaluates the recurrence relation, but even if you cannot do that, the recurrence relation gives you a way of evaluating the formula for successive values of $n$.
124.1 Theorem
If $A$ has $n$ elements, then there are $n$! different permutations of $A$.
To prove this, it is useful to prove something more general.
124.2 Theorem
The number of bijections between two $n$-element sets is $n$!.
Proof Let $P (n)$ be the number of bijections between two $n$-element sets. Then $P (0) =P(1) = 1$. Let $A$ and $B$ be two sets with $n+ 1$ elements. Let $a\in A$. Then in constructing a bijection from $A$ to $B$ we have $n+ 1$ choices for the value of the bijection at $a$. If we choose $b\in B$, then what is left is a bijection from $A- \{a\}$ to $B - \{b\}$. These are both $n$-element sets, so there are $P (n)$ of these, by definition of $P (n)$. Hence
$$P (n + 1) = (n + 1)\cdot P (n)$$
This is the recurrence relation which (with $P$(0) = 1) defines $n$! (see Section 105.1.6, page 158), so $P (n ) =n$!.
Here is another example of using recurrences in counting:
124.2.1 Worked Exercise Derive a formula or recurrence relation for the number of strings of length $n$ in $\{ 0, 1\}^{*}$ with an even number of 1’s.
Answer Let $F (n)$ be the number of such strings. Obviously $F (0) =F(1) = 1$. There are $F (n)$ strings of length $n$ with an even number of ones and $2^{n}-F (n)$ with an odd number of ones. (Note that there is no justification at this point for assuming that the number of strings of length $n$ with an even number of ones and the number with an odd number of ones are the same.) You can adjoin a 0 to a string of the first type and a 1 to a string of the second type to get a string of length $n+ 1$ with an even number of ones. Thus $F (n + 1) =F (n ) + 2^{n}-F (n ) = 2^{n}$. This is a case of a recurrence relation that solves itself!
124.2.2 Exercise Derive a formula or recurrence relation for the number of ways to arrange $n$ people around a circular table. (All that matters is who sits on each person’s left and who sits on his or her right.)
124.2.3 Exercise Derive a formula or recurrence relation for the amount of money in a savings account after $n$ years if the interest rate is $i$% compounded annually and you start with \$100.
Pages 189–190 of the book (PDF).