I was trying to get a closed form of the sum $$\sum_{k=1}^{n}k!$$
Mathematica gives the answer
$$(-1)^n\Gamma(n+2)(!(-n-2))-!(-1)-1$$
Here the ! sign before a number is the subfactorial. Here is my try:
\begin{align}
\sum_{k=1}^{n}k!&=\sum_{k=1}^{n}\Gamma(k+1)\\
&=\sum_{k=1}^{n}\int_{0}^{\infty}x^{k}e^{-x}dx\\
&=\int_{0}^{\infty}e^{-x}\sum_{k=1}^{n}x^kdx\\
&=\int_{0}^{\infty}\frac{e^{-x}(x-x^{n+1})}{1-x}dx
\end{align}
But I don't know what to do further. So, how can that closed form given by mathematica be derived?
Also, that closed form expression looks complex for some numbers to me. Is it even right?
2026-04-12 04:44:45.1775969085
Closed form of $\sum_{k=1}^{n}k!$
234 Views Asked by user840532 https://math.techqa.club/user/user840532/detail At
1
There are 1 best solutions below
Related Questions in SEQUENCES-AND-SERIES
- How to show that $k < m_1+2$?
- Justify an approximation of $\sum_{n=1}^\infty G_n/\binom{\frac{n}{2}+\frac{1}{2}}{\frac{n}{2}}$, where $G_n$ denotes the Gregory coefficients
- Negative Countdown
- Calculating the radius of convergence for $\sum _{n=1}^{\infty}\frac{\left(\sqrt{ n^2+n}-\sqrt{n^2+1}\right)^n}{n^2}z^n$
- Show that the sequence is bounded below 3
- A particular exercise on convergence of recursive sequence
- Proving whether function-series $f_n(x) = \frac{(-1)^nx}n$
- Powers of a simple matrix and Catalan numbers
- Convergence of a rational sequence to a irrational limit
- studying the convergence of a series:
Related Questions in SUMMATION
- Computing:$\sum_{n=0}^\infty\frac{3^n}{n!(n+3)}$
- Prove that $1+{1\over 1+{1\over 1+{1\over 1+{1\over 1+...}}}}=\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+...}}}}$
- Fourier series. Find the sum $\sum_{n=1}^\infty \frac{(-1)^{n+1}}{2n+1}$
- Sigma (sum) Problem
- How to prove the inequality $\frac{1}{n}+\frac{1}{n+1}+\cdots+\frac{1}{2n-1}\geq \log (2)$?
- Double-exponential sum (maybe it telescopes?)
- Simplify $\prod_{k=1}^{l} \sum_{r=d}^m {{m}\choose{r}} \left(N-k \right)^{r} k^{m-r+1}$
- Sum of two martingales
- How can we prove that $e^{-jωn}$ converges at $0$ while n -> infinity?
- Interesting inequalities
Related Questions in FACTORIAL
- How is $\frac{\left(2\left(n+1\right)\right)!}{\left(n+1\right)!}\cdot \frac{n!}{\left(2n\right)!}$ simplified like that?
- Remainder of $22!$ upon division with $23$?
- What is the name of this expression?
- How to compute $\left(\frac{n-1}{2}\right)!\pmod{n}$ fast?
- Proving $\sum_{k=1}^n kk!=(n+1)!−1$
- How do we know the Gamma function Γ(n) is ((n-1)!)?
- Approximate value of $15!$
- Limit of a Sequence involving factorials
- How to understand intuitively the fact that $\log(n!) = n\log(n) - n + O(\log(n))$?
- Deriving the fact that the approximation $\log(n!) \approx n\log(n) - n + \frac{1}{2}\log(2\pi n)$ is $O(1/n)$.
Related Questions in CLOSED-FORM
- How can I sum the series $e^{-2}\frac{(3)^n}{n!}\sum_{k=0}^{\infty}\left ( \frac{1}{2}\right )^k\frac{1}{(k-n)!}$
- Computing $\int_0^\pi \frac{dx}{1+a^2\cos^2(x)}$
- Can one solve $ \int_{0}^\infty\frac{\sin(xb)}{x^2+a^2}dx $ using contour integration?
- Finding a closed form for a simple product
- For what value(s) of $a$ does the inequality $\prod_{i=0}^{a}(n-i) \geq a^{a+1}$ hold?
- Convergence of $\ln\frac{x}{\ln\frac{x}{\ln x...}}$
- How can one show that $\int_{0}^{1}{x\ln{x}\ln(1-x^2)\over \sqrt{1-x^2}}\mathrm dx=4-{\pi^2\over 4}-\ln{4}?$
- Exercises about closed form formula of recursive sequence.
- Simplify and determine a closed form for a nested summation
- Direction in closed form of recurrence relation
Trending Questions
- Induction on the number of equations
- How to convince a math teacher of this simple and obvious fact?
- Find $E[XY|Y+Z=1 ]$
- Refuting the Anti-Cantor Cranks
- What are imaginary numbers?
- Determine the adjoint of $\tilde Q(x)$ for $\tilde Q(x)u:=(Qu)(x)$ where $Q:U→L^2(Ω,ℝ^d$ is a Hilbert-Schmidt operator and $U$ is a Hilbert space
- Why does this innovative method of subtraction from a third grader always work?
- How do we know that the number $1$ is not equal to the number $-1$?
- What are the Implications of having VΩ as a model for a theory?
- Defining a Galois Field based on primitive element versus polynomial?
- Can't find the relationship between two columns of numbers. Please Help
- Is computer science a branch of mathematics?
- Is there a bijection of $\mathbb{R}^n$ with itself such that the forward map is connected but the inverse is not?
- Identification of a quadrilateral as a trapezoid, rectangle, or square
- Generator of inertia group in function field extension
Popular # Hahtags
second-order-logic
numerical-methods
puzzle
logic
probability
number-theory
winding-number
real-analysis
integration
calculus
complex-analysis
sequences-and-series
proof-writing
set-theory
functions
homotopy-theory
elementary-number-theory
ordinary-differential-equations
circles
derivatives
game-theory
definite-integrals
elementary-set-theory
limits
multivariable-calculus
geometry
algebraic-number-theory
proof-verification
partial-derivative
algebra-precalculus
Popular Questions
- What is the integral of 1/x?
- How many squares actually ARE in this picture? Is this a trick question with no right answer?
- Is a matrix multiplied with its transpose something special?
- What is the difference between independent and mutually exclusive events?
- Visually stunning math concepts which are easy to explain
- taylor series of $\ln(1+x)$?
- How to tell if a set of vectors spans a space?
- Calculus question taking derivative to find horizontal tangent line
- How to determine if a function is one-to-one?
- Determine if vectors are linearly independent
- What does it mean to have a determinant equal to zero?
- Is this Batman equation for real?
- How to find perpendicular vector to another vector?
- How to find mean and median from histogram
- How many sides does a circle have?
I believe that this is possibly how Mathematica got its answer.
Extend the definition of the sum to negative upper indices: $$ \sum_{k=0}^nf(k)=-\sum_{k=n+1}^{-1}f(k)\tag1 $$ Extend the definition of factorial to negative numbers: $$ n!=\frac{(-1)^{-n-1}}{(-n-1)!}(-1)!\tag2 $$ Applying these extensions to the definition for $!n$, we get $$ \begin{align} !n &=\sum_{k=0}^n(-1)^k\frac{n!}{k!}\tag{3a}\\ &=-\sum_{k=n+1}^{-1}(-1)^k\frac{n!}{k!}\tag{3b}\\ &=-\sum_{k=n+1}^{-1}(-1)^n\frac{(-k-1)!}{(-n-1)!}\tag{3c} \end{align} $$ Explanation:
$\text{(3a)}$: normal definition of $!n$
$\text{(3b)}$: apply $(1)$
$\text{(3c)}$: apply $(2)$
Substituting $n\mapsto-n$ and $k\mapsto-k$, we get $$ !(-n)=\frac{(-1)^{n-1}}{(n-1)!}\sum_{k=1}^{n-1}(k-1)!\tag4 $$ Finally, substituing $n\mapsto n+2$ and $k\mapsto k+1$, we get $$ !(-n-2)=\frac{(-1)^{n+1}}{(n+1)!}\sum_{k=0}^nk!\tag5 $$ which then leads immediately to $$ \sum_{k=0}^nk!=(-1)^{n+1}!(-n-2)\overbrace{\ (n+1)!\ }^{\Gamma(n+2)}\tag6 $$ Formula $(6)$ agrees with what Mathematica gives, using $!(-1)=0$.
I note that my answer and Mathematica's gives a different exponent of $-1$ than in the question. Also, my answer includes $k=0$, so it is $1$ greater.
How Mathematica Actually Computes Subfactorial
Let $m\in\mathbb{Z}^+$ and $n+m\gt-1$.
Integrating by parts, we get $$ \frac1{n!}\int_{-1}^\infty x^ne^{-x}\,\mathrm{d}x=\frac{(-1)^n}{n!}e+\frac1{(n-1)!}\int_{-1}^\infty x^{n-1}e^{-x}\,\mathrm{d}x\tag7 $$ Thus, by induction we get $$ \frac1{n!}\int_{-1}^\infty x^ne^{-x}\,\mathrm{d}x=\sum_{k=0}^n\frac{(-1)^k}{k!}e\tag8 $$ and therefore, $$ \begin{align} !n &=\sum_{k=0}^n(-1)^k\frac{n!}{k!}\tag{9a}\\ &=\frac1e\int_{-1}^\infty x^ne^{-x}\,\mathrm{d}x\tag{9b}\\ &=\frac1e\,\Gamma(n+1,-1)\tag{9c}\\ &=\frac1e\,\Gamma(n+1)+\frac{e^{\pi in}}e\int_0^1x^ne^x\,\mathrm{d}x\tag{9d} \end{align} $$ Explanation:
$\text{(9a)}$: equation $(5)$ from this answer
$\text{(9b)}$: apply $(8)$
$\text{(9c)}$: definition of the Incomplete Gamma Function
$\text{(9d)}$: write $(-1)^n=e^{\pi in}$
I think $(-1)^n=e^{-\pi in}$ is just as reasonable a replacement, and better is to average the two, getting $(-1)^n=\cos(\pi n)$. This also has the benefit of keeping $!n\in\mathbb{R}$ for $n\in\mathbb{R}$. However, we will continue with this, as this seems to be what Mathematica does.
First, a recurrence for the integral in $\text{(9d)}$: $$ \begin{align} \frac1{n!}\int_0^1x^ne^x\,\mathrm{d}x &=e\frac1{(n+1)!}-\frac1{(n+1)!}\int_0^1x^{n+1}e^x\,\mathrm{d}x\tag{10a}\\ &=-e\sum_{k=1}^m\frac{(-1)^k}{(n+k)!}+\frac{(-1)^m}{(n+m)!}\int_0^1x^{n+m}e^x\,\mathrm{d}x\tag{10b} \end{align} $$ Explanation:
$\text{(10a)}$: integration by parts
$\text{(10b)}$: induction on $m$ using $\text{(10a)}$ $$ \begin{align} \frac1e\int_0^1x^ne^x\,\mathrm{d}x &=-\sum_{k=1}^m\frac1{k!\binom{-n-1}{k}}+\frac1{m!\binom{-n-1}{m}}\frac1e\int_0^1x^{n+m}e^x\,\mathrm{d}x\tag{11a}\\ &=-\sum_{k=1}^{m-1}\frac1{k!\binom{-n-1}{k}}-\frac1{m!\binom{-n-1}{m}}\left(1-\frac1e\int_0^1x^{n+m}e^x\,\mathrm{d}x\right)\tag{11b} \end{align} $$ Explanation:
$\text{(11a)}$: multiply $(10)$ by $n!/e$ and use $\frac{(-1)^k(n+k)!}{n!}=k!\binom{-n-1}{k}$
$\text{(11b)}$: move the $k=m$ term from the sum to the right
$$ \begin{align} !n &=\overbrace{\frac{(-1)^m\Gamma(n+m+1)}{e\,m!\binom{-n-1}{m}}}^{\frac1e\Gamma(n+1)}\\ &-\sum_{k=1}^{m-1}\frac{e^{\pi in}}{k!\binom{-n-1}{k}}-\frac{e^{\pi in}}{m!\binom{-n-1}{m}}\left(1-\frac1e\int_0^1x^{n+m}e^x\,\mathrm{d}x\right)\tag{12a}\\[6pt] &=\frac{e^{\pi in}\left(e-\int_0^1x^{n+m}e^x\,\mathrm{d}x\right)-(-1)^m\Gamma(n+m+1)}{e\,(m-1)!\binom{-n-1}{m-1}(n+m)}\\ &-\sum_{k=1}^{m-1}\frac{e^{\pi in}}{k!\binom{-n-1}{k}}\tag{12b} \end{align} $$ Explanation:
$\text{(12a)}$: $\text{(9d)}$, $\text{(11b)}$, and $\Gamma(z+1)=z\,\Gamma(z)$
$\text{(12b)}$: commute terms and use $m!\binom{-n-1}{m}=-(m-1)!\binom{-n-1}{m-1}(n+m)$
Let $n\to-m^+$, then $\text{(12b)}$ and L'Hôpital yield $$ \begin{align} !(-m) &=(-1)^m\left[\frac{\gamma-\int_0^1\log(x)\,e^x\,\mathrm{d}x}{e\,(m-1)!}-\sum_{k=1}^{m-1}\frac1{k!\binom{m-1}{k}}\right]+\frac{(-1)^m\pi i}{e\,(m-1)!}\tag{13a}\\ &=\frac{(-1)^m}{(m-1)!}\left[\frac{\gamma+\pi i-\int_0^1\log(x)\,e^x\,\mathrm{d}x}e-\sum_{k=1}^{m-1}(k-1)!\right]\tag{13b} \end{align} $$ where $\gamma$ is the Euler-Mascheroni Constant, which is computed in this answer, and $$ \begin{align} \int_0^1\log(x)\,e^x\,\mathrm{d}x &=\gamma-\operatorname{Ei}(1)\tag{14a}\\ &=-\sum_{k=1}^\infty\frac1{k\,k!}\tag{14b}\\ \end{align} $$ where $\operatorname{Ei}(x)$ is the Exponential Integral.
The values given in $\text{(13b)}$ match those returned by Mathematica for
Subfactorial.Thus, substituting $m\mapsto m+2$ and $k\mapsto k+1$ in $\text{(13b)}$, we get $$ \begin{align} \sum_{k=0}^mk! &=(-1)^{m+1}!(-m-2)(m+1)!+\frac{\gamma+\pi i-\int_0^1\log(x)\,e^x\,\mathrm{d}x}e\tag{15a}\\ &=(-1)^{m+1}!(-m-2)(m+1)!\,-\,!(-1)\tag{15b} \end{align} $$