# Let’s calculate the sum of factorials!

Hello, guys! It’s me! Warotan!

Japanese version.

## Factorial of a natural number

A factorial of a natural number is defined as

$$\begin{eqnarray} n! \equiv n\left(n-1\right)\left(n-2\right)\cdots 3\cdot 2\cdot 1 \end{eqnarray}$$

Let us consider the summation of the factorials from 1 to $$n$$,

$$\begin{eqnarray} S_{n} \equiv \sum_{k=1}^{n}k! \end{eqnarray}$$

## Transforming $$k!$$

It is difficult to directly calculate the sum, so we do a little transforming.
With a permutation $$_{n}P_{k} = \frac{n!}{\left(n-k\right)!}$$,

$$\begin{eqnarray} S_{n} &=& \sum_{k=1}^{n}k! \\ &=& \sum_{k=0}^{n-1}\left(n-k\right)! \\ &=& \sum_{k=0}^{n-1}n!/ _{n}P_{k} \\ &=& n!\sum_{k=0}^{n-1} 1/ _{n}P_{k} \end{eqnarray}$$

In fact, we can find this summation.

## This is where the $$\Gamma$$ function comes in

Do you remember the $$\Gamma$$ function that I wrote about before? (English version coming soon)
Here, it is the turn of a variant, the incomplete $$\Gamma$$ function.

The incomplete $$\Gamma$$ function is defined as

$$\begin{eqnarray} \Gamma\left(a,x\right) \equiv \int_{x}^{\infty}{\rm e}^{-t}t^{a-1}{\rm d}t \end{eqnarray}$$

For $$a>0$$, integrating by parts,

$$\begin{eqnarray} \Gamma\left(-a,x\right) &=& \int_{x}^{\infty}{\rm e}^{-t}\frac{1}{-a}\frac{{\rm d}}{{\rm d}t}t^{-a}{\rm d}t \\ &=& \frac{1}{-a}{\rm e}^{-t}t^{-a}|_{t\to\infty}-\frac{1}{a}{\rm e}^{-x}x^{-a}-\frac{1}{a}\int_{x}^{\infty}{\rm e}^{-t}t^{-a}{\rm d}t \\ &=& -\frac{1}{a}{\rm e}^{-x}x^{-a}-\frac{1}{a}\Gamma\left(-a+1,x\right) \end{eqnarray}$$

A recurrence formula appears.
Repeating this, we get

$$\begin{eqnarray} \Gamma\left(-a,x\right) &=& -\frac{1}{a}{\rm e}^{-x}x^{a}-\frac{1}{a\left(1-a\right)}{\rm e}^{-x}x^{1-a}-\frac{1}{a\left(1-a\right)\left(2-a\right)}{\rm e}^{-x}x^{2-a} \\ &-& \cdots -\frac{1}{a\left(1-a\right)\left(2-a\right)\cdots\left(n-a-1\right)}{\rm e}^{-x}x^{n-a-1} \\ &-& \frac{1}{a\left(1-a\right)\left(2-a\right)\cdots\left(n-a-1\right)}\Gamma\left(n-a,x\right) \\ &=& {\rm e}^{-x}\sum_{k=1}^{n}\left(-1\right)^{k}\frac{1}{ _{a}P_{k}}x^{k-a}-\Gamma\left(n-a,x\right) \end{eqnarray}$$

If $$a = n,\,x = 1$$,

$$\begin{eqnarray} \Gamma\left(-n,-1\right) &=& {\rm e}\sum_{k=1}^{n}\left(-1\right)^{2k-n}\frac{1}{ _{n}P_{k}}-\Gamma\left(0,-1\right) \\ &=& \left(-1\right)^{n}{\rm e}\sum_{k=1}^{n}\frac{1}{ _{n}P_{k}}-\Gamma\left(0,-1\right) \end{eqnarray}$$

We did it!
It includes $$\sum_{k}\frac{1}{ _{n}P_{k}}$$.
From this equation,

$$\begin{eqnarray} \sum_{k=1}^{n}\frac{1}{ _{n}P_{k}} = \left(-1\right)^{n}{\rm e}^{-1}\left[\Gamma\left(-n,-1\right)-\Gamma\left(0,-1\right)\right], \end{eqnarray}$$

and therefore,

$$\begin{eqnarray} S_{n} &=& n!\sum_{k=0}^{n-1}\frac{1}{ _{n}P_{k}} \\ &=& n!\left[\sum_{k=1}^{n}\frac{1}{ _{n}P_{k}}+\frac{1}{_{n}P_{0}}-\frac{1}{ _{n}P_{n}}\right] \\ &=& n!\left[\left(-1\right)^{n}{\rm e}^{-1}\left[\Gamma\left(-n,-1\right)-\Gamma\left(0,-1\right)\right]+1-\frac{1}{n!}\right] \\ &=& n!\left(-1\right)^{n}{\rm e}^{-1}\left[\Gamma\left(-n,-1\right)-\Gamma\left(0,-1\right)\right]+n!-1 \end{eqnarray}$$

## Summary

Now, that’s all what I wanted to write.

This time, we found the summation of factorials.
It is the summation of integers, but the story didn’t fit within integers.