Derangements:
A Derangement is a permutation, $P$, in which no element is mapped to itself; that is, $P(k)\ne k$, for $1\le k\le n$. Let $\mathcal{D}(n)$ be the number of derangements of $n$ items.
Here are a few methods of computing $\mathcal{D}(n)$.
Method 1 (build from smaller derangements):
Let us count the number of derangements of $n$ items so that $P(P(n))=n$. There are $n-1$ choices for $P(n)$, and for each of those choices, $\mathcal{D}(n-2)$ ways to arrange the other $n-2$ items. Thus, there are $(n-1)\mathcal{D}(n-2)$ derangements of $n$ items so that $P(P(n))=n$.
Let us count the number of derangements of $n$ items so that $P(P(n))\not=n$. There are $n-1$ choices for $P(n)$, and for each choice, there is a derangement of $n-1$ items identical to $P$ except that they map $P^{-1}(n)\to P(n)$. Thus, there are $(n-1)\mathcal{D}(n-1)$ derangements of $n$ items so that $P(P(n))\not=n$.
Therefore,
$$
\mathcal{D}(n)=(n-1)(\mathcal{D}(n-1)+\mathcal{D}(n-2))\tag{1}
$$
Method 2 (count permutations):
Count the number of permutations of $n$ items by counting how many fix exactly $k$ items.
There are $\binom{n}{k}$ ways to choose the $k$ items to fix, then $\mathcal{D}(n-k)$ ways to arrange the $n-k$ items that are not fixed. Since there are $n!$ permutations of $n$ items, we get
$$
n!=\sum_{k=0}^n\binom{n}{k}\mathcal{D}(n-k)\tag{2}
$$
and therefore, rearranging $(2)$ yields
$$
\mathcal{D}(n)=n!-\sum_{k=1}^n\binom{n}{k}\mathcal{D}(n-k)\tag{3}
$$
Method 3 (inclusion-exclusion):
Let $S_i$ be the set of permutations of $n$ items which fix item $i$. Then the number of permutations in $k$ of the $S_i$ would be the number of permutations that fix $k$ items. There are $\binom{n}{k}$ ways to choose the $k$ items to fix, and $(n-k)!$ ways to arrange the other $n-k$ items. Thus, the number of permutations that fix at least $1$ item would be
$$
\sum_{k=1}^n(-1)^{k-1}\binom{n}{k}(n-k)!=\sum_{k=1}^n(-1)^{k-1}\frac{n!}{k!}\tag{4}
$$
Since there are $n!$ permutations in total, the number of permutations that don't fix any items is
$$
\begin{align}
\mathcal{D}(n)
&=n!-\sum_{k=1}^n(-1)^{k-1}\frac{n!}{k!}\\
&=\sum_{k=0}^n(-1)^k\frac{n!}{k!}\tag{5}\\
&\approx \frac{n!}{e}
\end{align}
$$
In fact, the difference
$$
\begin{align}
\left|\frac{n!}{e}-\mathcal{D}(n)\right|
&=\left|\sum_{k=n+1}^\infty(-1)^k\frac{n!}{k!}\right|\\
&=\left|\frac{1}{n+1}-\frac{1}{(n+1)(n+2)}+\frac{1}{(n+1)(n+2)(n+3)}-\dots\right|\\
&<\frac{1}{n+1}\tag{6}
\end{align}
$$
This method yields directly that $\mathcal{D}(n)$ is the closest integer to $\frac{n!}{e}$ for $n>0$.
Derivation of the Closed Form from the Recursion:
Given $\mathcal{D}(0)=1$ and $\mathcal{D}(1)=0$, and the recursion $(1)$, let's derive $(5)$. Subtracting $n\mathcal{D}(n-1)$ from both sides of $(1)$ yields
$$
\mathcal{D}(n)-n\mathcal{D}(n-1)=-(\mathcal{D}(n-1)-(n-1)\mathcal{D}(n-2))\tag{7}
$$
Using the initial conditions, $(7)$ implies
$$
\mathcal{D}(n)-n\mathcal{D}(n-1)=(-1)^n\tag{8}
$$
Dividing both sides of $(8)$ by $n!$ yields
$$
\frac{\mathcal{D}(n)}{n!}-\frac{\mathcal{D}(n-1)}{(n-1)!}=\frac{(-1)^n}{n!}\tag{9}
$$
Equation $(9)$ is very simple to solve for $\frac{\mathcal{D}(n)}{n!}$:
$$
\frac{\mathcal{D}(n)}{n!}=\sum_{k=0}^n\frac{(-1)^k}{k!}+C\tag{10}
$$
Plugging $n=0$ into equation $(10)$ yields that $C=0$. Therefore,
$$
\mathcal{D}(n)=n!\sum_{k=0}^n\frac{(-1)^k}{k!}\tag{11}
$$
Incomplete Gamma Function:
$$
\begin{align}
\mathcal{D}(n)
&=n!\sum_{k=0}^n\frac{(-1)^k}{k!}\tag{12a}\\
&=\sum_{k=0}^n(-1)^k\frac{n!}{k!}\tag{12b}\\
&=\sum_{k=0}^n(-1)^k\binom{n}{k}(n-k)!\tag{12c}\\
&=\sum_{k=0}^n(-1)^k\binom{n}{k}\int_0^\infty x^{n-k}e^{-x}\,\mathrm{d}x\tag{12d}\\
&=\int_0^\infty\sum_{k=0}^n\binom{n}{k}(-1)^kx^{n-k}e^{-x}\,\mathrm{d}x\tag{12e}\\
&=\int_0^\infty(x-1)^ne^{-x}\,\mathrm{d}x\tag{12f}\\
&=\frac1e\int_{-1}^\infty x^ne^{-x}\,\mathrm{d}x\tag{12g}\\
&=\frac1e\Gamma(n+1,-1)\tag{12h}
\end{align}
$$
Explanation:
$\text{(12a):}$ $(11)$
$\text{(12b):}$ bring the factor of $n!$ inside the sum
$\text{(12c):}$ $\frac{n!}{k!}=\binom{n}{k}(n-k)!$
$\text{(12d):}$ $n!=\int_0^\infty x^ne^{-x}\,\mathrm{d}x$
$\text{(12e):}$ swap the finite sum and the integral
$\text{(12f):}$ apply the Binomial Theorem
$\text{(12g):}$ substitute $x\mapsto x+1$
$\text{(12h):}$ $\Gamma(n,s)=\int_s^\infty x^{n-1}e^{-x}\,\mathrm{d}x$ is the Incomplete Gamma Function
Negative Integer Arguments:$\newcommand{\Ei}{\operatorname{Ei}}\newcommand{\PV}{\operatorname{PV}}$
$$
\begin{align}
\mathcal{D}(-1)
&=\frac1e\int_{-1}^\infty\frac{e^{-x}}x\,\mathrm{d}x\tag{13a}\\
&=-\frac{\Ei(1)+\pi i}e\tag{13b}
\end{align}
$$
Explanation:
$\text{(13a):}$ apply $\text{(12g)}$
$\text{(13b):}$ $\Ei(z)=-\PV\int_{-z}^\infty\frac{e^{-t}}{t}\,\mathrm{d}t$
$\phantom{\text{(13b):}}$ the infinitesimal clockwise semicircle
$\phantom{\text{(13b):}}$ around the singularity at $0$ gives $-\pi i$
For $n\ge2$,
$$
\begin{align}
\mathcal{D}(-n)
&=\frac1e\int_{-1}^\infty x^{-n}e^{-x}\,\mathrm{d}x\tag{14a}\\
&=-\frac1{n-1}\frac1e\int_{-1}^\infty e^{-x}\,\mathrm{d}x^{1-n}\tag{14b}\\
&=-\frac1{n-1}\frac1e\left((-1)^ne+\int_{-1}^\infty x^{1-n}e^{-x}\mathrm{d}x\right)\tag{14c}\\
&=\frac{(-1)^{n-1}}{n-1}-\frac1{n-1}\frac1e\int_{-1}^\infty x^{1-n}e^{-x}\mathrm{d}x\tag{14d}\\
&=\frac{(-1)^{n-1}}{n-1}-\frac1{n-1}\mathcal{D}(1-n)\tag{14e}
\end{align}
$$
Explanation:
$\text{(14a):}$ apply $\text{(12g)}$
$\text{(14b):}$ prepare to integrate by parts
$\text{(14c):}$ integrate by parts
$\text{(14d):}$ distribute
$\text{(14e):}$ apply $\text{(12g)}$
Multiply $(14)$ by $(-1)^{n-1}(n-1)!$ and apply induction:
$$
\begin{align}
(-1)^{n-1}(n-1)!\mathcal{D}(-n)
&=(n-2)!+(-1)^{n-2}(n-2)!\mathcal{D}(1-n)\tag{15a}\\
&=\sum_{k=0}^{n-2}k!+\mathcal{D}(-1)\tag{15b}
\end{align}
$$
Combine $(13)$ and $(15)$ and divide by $(-1)^{n-1}(n-1)!$:
$$
\mathcal{D}(-n)=\frac{(-1)^{n-1}}{(n-1)!}\left(\sum_{k=0}^{n-2}k!-\frac{\Ei(1)+\pi i}e\right)\tag{16}
$$