21. Find the number of eight-digit integers comprising the eight digits from 1 to 8 such that $(i+1)$ does not immediately follow $i$ for all $i$ that runs from 1 to 7 .
21. Answer: 16687.
We may proceed by using the principle of inclusion and exclusion as follows. Let the universal set $S$ be the set of 8 -digit integers comprising the 8 digits from 1 to 8 . Let $P_{1}(1 \leq i \leq 7)$ be the property that $(i+1)$ immediately follows $i$ in an element of $S$. Hence $W(0)=8!, W(i)=(7)(8-i)!$ for $1 \leq i \leq 7$. Then the answer $=E(0)=$ $W(0)-W(1)+W(2)-\cdots-W(7)=16687$. The answer can also be obtained from either one of the two expressions, namely, $\frac{1}{8} D_{9}$ or $D_{8}+D_{7}$, where $D_{n}$ is the number of derangements of the integers from 1 to $n$ and $D_{n}=n!\left[1-\frac{1}{1}+\frac{1}{2}-\frac{1}{3}+\cdots+(-1)^{n} \frac{1}{n!}\right]$.