Why n! equals sum of some expression? Why n! equals sum of some expression?
Especially I need to know why this expression is true?
$$
n!= \left(\frac{n+1}{2}\right)^{p(n)} \; \prod_{j=0}^{q(n)}\sum_{i=0}^j(n-2i),
$$
Where
\begin{gather*}
p(n)=\frac{\cos(\pi n+\pi)+1}{2}\\\\
q(n)=\frac{2n+\cos(\pi n)-5}4
\end{gather*}
How to prove this equality?
Is it true?
 A: Summary:
This formula is just a convoluted way of saying,
$$
n! = [n \cdot 1][(n-1) \cdot 2][(n-2) \cdot 3] \cdots 
\left\{
\begin{array}{cc}
\left[ \frac{n+1}{2} \right] & n \text{ is odd} \\
\left[\frac{n}{2} \cdot \frac{n+2}{2} \right] & n \text{ is even}
\end{array}
\right.
$$
Explanation:
Note that by sum of an arithmetic sequence,
$$
\sum_{i = 0}^j (n - 2i) = (n - j)(j+1)
$$
Also,
$$
\frac{2n + \cos(\pi n) - 5}{4}
=
\frac{2n + (-1)^n - 5}{4}
=
\left\{
\begin{array}{cc}
\frac{n - 3}{2} & n \text{ is odd}\\
\frac{n - 2}{2} & n \text{ is even}
\end{array}
\right.
$$
Finally,
$$
{\left(\frac{n+1}{2}\right)}^{\left(\frac{\cos(\pi n + \pi)+1}{2}\right)}
=
{\left(\frac{n+1}{2}\right)}^{\left(\frac{(-1)^{n+1}+1}{2}\right)}
=
\left\{
\begin{array}{cc}
\frac{n + 1}{2} & n \text{ is odd}\\
1 & n \text{ is even}
\end{array}
\right.
$$
Thus, if $n$ is odd,
\begin{align*}
{\left(\frac{n+1}{2}\right)}^{\left(\frac{\cos(\pi n + \pi)+1}{2}\right)}  \prod_{j=0}^\frac{2 n +\cos(\pi n) - 5}{4}\sum_{i=0}^j(n-2i)
&=
\frac{n+1}{2} \prod_{j=0}^{\frac{n - 3}{2}} (n - j)(j+1) \\
&= \frac{n+1}{2} [n \cdot 1][(n-1) \cdot 2] \cdots \left[ \left( \frac{n + 3}{2} \right) \left( \frac{n-1}{2} \right) \right] \\
&= n!
\end{align*}
And if $n$ is even,
\begin{align*}
{\left(\frac{n+1}{2}\right)}^{\left(\frac{\cos(\pi n + \pi)+1}{2}\right)}  \prod_{j=0}^\frac{2 n +\cos(\pi n) - 5}{4}\sum_{i=0}^j(n-2i)
&=
1 \cdot \prod_{j=0}^{\frac{n - 2}{2}} (n - j)(j+1) \\
&= [n \cdot 1][(n-1) \cdot 2] \cdots \left[ \left( \frac{n + 2}{2} \right) \left( \frac{n}{2} \right) \right] \\
&= n!
\end{align*}
So indeed the formula holds for any $n$.
