I am curious to see how to solve the following problem:
Let $$I(n)=\int_0^{\infty}(t-1)^ne^{-t}dt$$ If $D(n)$ is the number of derangements of $n$, then what is $I(42)-D(42)$.
This problem is found on the bottom of this page: https://brilliant.org/wiki/derangements/
I know \begin{align*}I(42)&=\int_0^{\infty}(t-1)^{42}e^{-t}dt,\\ D(42)&=42!\sum_{k=0}^{42}\frac{(-1)^k}{k!},\\ e^x&=\sum_{i=0}^\infty\frac{x^i}{i!},\end{align*} but I am not sure how to connect these pieces together. Any suggestions?
$$ \begin{align} I(n) &= \int_{0}^{\infty}\left(t-1\right)^{n}e^{-t}dt \\ &= \int_{0}^{\infty}\sum_{k=0}^{n}\binom{n}{k}t^{n-k}\left(-1\right)^{k}e^{-t}dt \\ &= \sum_{k=0}^{n}\binom{n}{k}\left(-1\right)^{k}\int_{0}^{\infty}t^{n-k}e^{-t}dt \\ &= \sum_{k=0}^{n}\binom{n}{k}\left(-1\right)^{k}(n-k)! \\ &= \sum_{k=0}^{n}\frac{n!}{k!(n-k)!}\left(-1\right)^{k}(n-k)! \\ &= n!\sum_{k=0}^{n}\frac{\left(-1\right)^{k}}{k!} \\ &= D(n) \\ \end{align} $$
Which implies that $I(n) - D(n) = 0$. Let $n=42$ and we are done.