Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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} $$


$$ 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! $$


$$ {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.

share|cite|improve this question
I doubt there is such a formula. Note that the last digit of your sum is constant and equal to $1+2+6+4=3$. It would be hard to have a general formula which gives you the same last digit... (I think) – Beni Bogosel Nov 2 '12 at 14:25
Mathematica says that: $$\sum_{n=1}^{N}{n!}=-1-(-1)¡-(-1)^{N}\cdot\Gamma{(2+N)}\cdot(-N-2)¡,$$ where $n¡$ is the subfactorial – Shaktal Nov 2 '12 at 14:28
See also: – leonbloy Jan 14 '13 at 12:26

(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.

share|cite|improve this answer

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} $$

share|cite|improve this answer

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

More on Ei

share|cite|improve this answer

protected by Community Apr 24 '14 at 15:32

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.