Derangement Recurrence
1. **Problem Statement:** We need to prove the recurrence relation $$D_n = nD_{n-1} + (-1)^n$$ for $$n \geq 1$$, where $$D_n$$ is defined as in Exercise 18 (usually the number of derangements or a similar combinatorial function).
2. **Recall Exercise 18:** Typically, Exercise 18 defines $$D_n$$ as the number of derangements of $$n$$ objects, which satisfies the formula:
$$D_n = nD_{n-1} + (-1)^n$$
We want to verify this formula holds.
3. **Base Case:** For $$n=1$$,
$$D_1 = 1 \cdot D_0 + (-1)^1 = 1 \cdot 1 - 1 = 0$$
This matches the known value $$D_1=0$$ (no derangements of one object).
4. **Inductive Step:** Assume the formula holds for $$n-1$$, i.e.,
$$D_{n-1} = (n-1)D_{n-2} + (-1)^{n-1}$$
5. **Use the known formula for derangements:**
$$D_n = (n-1)(D_{n-1} + D_{n-2})$$
6. **Substitute the inductive hypothesis into the formula:**
$$D_n = (n-1)\left(D_{n-1} + D_{n-2}\right)$$
7. **Rewrite $$D_{n-2}$$ from the inductive hypothesis:**
From step 4,
$$D_{n-1} = (n-1)D_{n-2} + (-1)^{n-1} \implies D_{n-2} = \frac{D_{n-1} - (-1)^{n-1}}{n-1}$$
8. **Substitute $$D_{n-2}$$ back:**
$$D_n = (n-1)\left(D_{n-1} + \frac{D_{n-1} - (-1)^{n-1}}{n-1}\right) = (n-1)D_{n-1} + D_{n-1} - (-1)^{n-1} = nD_{n-1} - (-1)^{n-1}$$
9. **Simplify the sign:**
Note that $$-(-1)^{n-1} = (-1)^n$$ because $$-(-1)^{n-1} = (-1)^1 \cdot (-1)^{n-1} = (-1)^n$$.
10. **Final formula:**
$$D_n = nD_{n-1} + (-1)^n$$
This completes the proof.
**Answer:** The recurrence relation $$D_n = nD_{n-1} + (-1)^n$$ holds for all $$n \geq 1$$.