70

I came across a question where I needed to find the sum of the factorials of the first $n$ numbers. So I was wondering if there is any generic formula for this?

Like there is a generic formula for the series:

$$ 1 + 2 + 3 + 4 + \cdots + n = \frac{n(n+1)}{2} $$

or

$$ 1^{2} + 2^{2} + 3^{2} + 4^{2} + \cdots + n^{2} = \frac{n(n+1)(2n + 1)}{6} $$

Is there is any formula for:

$$ 1! +2! +3! + 4! + \cdots + n! $$

and

$$ {1!}^2 +{2!}^2 +{3!}^2 + \cdots + {n!}^2 $$?

Thanks in advance.

If not, is there any research on making this type of formula? Because I am interested.

vikiiii
  • 2,533
  • 2
  • 30
  • 44
  • 16
    Mathematica says that: $$\sum_{n=1}^{N}{n!}=-1-(-1)¡-(-1)^{N}\cdot\Gamma{(2+N)}\cdot(-N-2)¡,$$ where $n¡$ is the [subfactorial](http://www.artofproblemsolving.com/Wiki/index.php/Derangement) – Thomas Russell Nov 02 '12 at 14:28
  • 2
    See also: http://mathworld.wolfram.com/FactorialSums.html – leonbloy Jan 14 '13 at 12:26
  • I'd recommend checking out [Euler's continued fraction formula](https://en.wikipedia.org/wiki/Euler%27s_continued_fraction_formula#Euler's_formula). However, also note: $$\sum_{n=1}^{N}n!=1+2\left(1+3\left(1+4(1+\dots)\right)\right)$$ – Void Aug 18 '20 at 19:01
  • 4
    Not an answer to your question, but there is the following related identity: $$ \sum_{k = 0}^n k \cdot k! = (n + 1)! - 1 $$ – Ruben Jan 30 '21 at 10:56

3 Answers3

41

(Too long for a comment)

I don't know if there's a simpler form, but the sum of factorials has certainly been well-studied. In the literature, it is referred to as either the left factorial (though this term is also used for the more common subfactorial) or the Kurepa function (after the Balkan mathematician Đuro Kurepa).

In particular, for $K(n)=\sum\limits_{j=0}^{n-1}j!$ (using the notation $K(n)$ after Kurepa), we have as an analytic continuation the integral representation

$$K(z)=\int_0^\infty \exp(-t)\frac{t^z-1}{t-1}\mathrm dt,\quad \Re z>0$$

and a further continuation to the left half-plane is possible from the functional equation $K(z)-K(z-1)=\Gamma(z)$

An expression in terms of "more usual" special functions, equivalent to the one in Shaktal's comment, is

$$K(z)=\frac1{e}\left(\Gamma(z+1) E_{z+1}(-1)+\mathrm{Ei}(1)+\pi i\right)$$

where $E_p(z)$ and $\mathrm{Ei}(z)$ are the exponential integrals.

The sum of squares of factorials does not seem to have a simple closed form, but the sequence is listed in the OEIS. One can, however, derive an integral representation that could probably be used as a starting point for analytic continuation. In particular, we have

$$\sum_{j=0}^{n-1}(j!)^2=2\int_0^\infty \frac{t^n-1}{t-1} K_0(2\sqrt t)\mathrm dt$$

where $K_0(z)$ is the modified Bessel function of the second kind.

J. M. ain't a mathematician
  • 71,951
  • 6
  • 191
  • 335
36

In addition to the special functions given by J.M., an asymptotic expansion can be computed $$ \begin{align} \sum_{k=0}^n k! &=n!\left(\frac11+\frac1n+\frac1{n(n-1)}+\frac1{n(n-1)(n-2)}+\dots\right)\\ &=n!\left(1+\frac1n+\frac1{n^2}+\frac2{n^3}+\frac5{n^4}+\frac{15}{n^5}+O\left(\frac1{n^6}\right)\right)\\ &=\sqrt{2\pi n}\frac{n^n}{e^n}\left(1+\frac{13}{12n}+\frac{313}{288n^2}+\frac{108041}{51840n^3}+\frac{12857717}{2488320n^4}+O\left(\frac1{n^5}\right)\right) \end{align} $$ As with most asymptotic expansions, the series does not converge, and cannot be used to get an exact answer, but it gives a good approximation.

Edit: I forgot to give $$ \begin{align} \sum_{k=0}^nk!^2 &=n!^2\left(\frac11+\frac1{n^2}+\frac1{n^2(n-1)^2}+\frac1{n^2(n-1)^2(n-2)^2}+\dots\right)\\ &=n!^2\left(1+\frac1{n^2}+\frac1{n^4}+\frac2{n^5}+\frac4{n^6}+\frac{10}{n^7}+O\left(\frac1{n^8}\right)\right)\\ &=2\pi\frac{n^{2n+1}}{e^{2n}}\left(1+\frac1{6n}+\frac{73}{72n^2}+\frac{1049}{6480n^3}+\frac{157541}{155520n^4}+O\left(\frac1{n^5}\right)\right) \end{align} $$

robjohn
  • 326,069
  • 34
  • 421
  • 800
8

For what concerns the first one, yes there is.

$$\sum_{k = 0}^{n} k! = \frac{i\pi}{e} + \frac{\text{Ei}(1)}{e} - \frac{(-1)^n\ \Gamma[n+2]\ \Gamma[-n-1, -1]}{e}$$

Where Ei is the Exponential Integral function, and $\Gamma[x]$ is the Euler Gamma Function whilst $\Gamma[x, n]$ is the upper incomplete Gamma Function.

More on IGF

https://en.wikipedia.org/wiki/Incomplete_gamma_function

More on Ei

https://en.wikipedia.org/wiki/Exponential_integral

Laplacian
  • 23,646
  • 9
  • 34
  • 53