Prove $\pi\int_{0}^{\infty}{(1+e^{-x\pi})^{-n}\over 1+\cosh(x\pi)}dx={1+2+2^2+\cdots+2^{n-1}\cdot3\over 2^n(n+1)}$ 
$$I=\pi\int_{0}^{\infty}{(1+e^{-x\pi})^{-n}\over 1+\cosh(x\pi)}dx=\color{blue}{1+2+2^2+\cdots+2^{n-1}\cdot3\over 2^n(n+1)}\tag1$$

Recall 
$1+\cosh(x\pi)={(e^x+1)^2\over 2e^x}$
$$I=2\pi\int_{0}^{\infty}{e^x(1+e^{-x\pi})^{-n}\over (1+e^x)^2}dx\tag2$$
$$(1+e^x)^{-2}=\sum_{n=0}^{\infty}(-1)^n(n+1)e^{nx}$$
Sub into (2)$\rightarrow (3)$
$$I=2\pi\sum_{n=0}^{\infty}(-1)^n(1+n)\int_{0}^{\infty}e^{x(1+n)}(1+e^{-x\pi})^{-n}dx\tag3$$
Recall 
$$(1+e^{-x\pi})^{-n}=1-{n\choose 1}e^{-x\pi}+{n\choose 2}e^{-2x\pi}-{n\choose 3}e^{-3x\pi}+\cdots$$
Sub into (3)$\rightarrow (4)$
$$I=2\pi\sum_{n=0}^{\infty}(-1)^n(1+n)\int_{0}^{\infty}e^{x(1+n)}-{n\choose 1}e^{x(1+n-\pi)}+{n\choose 2}e^{x(1+n-\pi)}-\cdots dx \tag4$$
Problem
$\int_{0}^{\infty}e^{x(1+n)}dx$ Diverges
Why did I goes wrong? Help please. Thank!
 A: 
There were a few errors in the development in the OP.
First, the identity for $1+\cosh(\pi x)$ is written incorrectly as the scale factor $\pi$ is missing.
Second, the factoring of $e^{-\pi x}$, or $e^{-x}$ in the OP, leads to a problem later.
Third, the index $n$ is fixed while the index it the series expansion of the term $(1+e^{\pi x})^2$ is a "dummy index" and needs to be distinguished from $n$.
Four, in the expansion for $(1+e^{\pi x})^2$, the term $(n+1)$ should be replaced with $n$.
Five, the interchange of summation and integration is not legitimate since the original integral converges, but the term-by-term integration does not.
To that end, we present now a straightforward approach to evaluating the integral of interest.


Let $I_n$ be defined by the integral
$$I_n=\pi \int_0^\infty \frac{(1+e^{-\pi x})^{-n}}{1+\cosh(\pi x)}\,dx \tag 1$$
First, we enforce the substitution $x\to x/\pi$ in $(1)$ to obtain
$$I_n =\int_0^\infty \frac{(1+e^{- x})^{-n}}{1+\cosh( x)}\,dx \tag 2$$
Next, exploiting the identity $1+\cosh(x)=e^{x}\frac{(1+e^{- x})^2}{2}$ in $(2)$ reveals 
$$\begin{align}
I_n&=2\int_0^\infty \frac{e^{-x}}{(1+e^{- x})^{n+2}}\,dx\\\\
&=2\frac{1}{n+1}\left(1-\frac{1}{2^{n+1}}\right)\\\\
&=\frac{1}{2^n(n+1)}\left(2^{n+1}-1\right)
\end{align}$$
Finally, we note that 
$$\begin{align}
2^{n+1}-1&=\sum_{k=0}^n 2^k\\\\
&=\sum_{k=0}^{n-2} 2^k+3\left(2^{n-1}\right)\\\\
&=1+2+2^2+\cdots +2^{n-1}\cdot 3
\end{align}$$
And we are done!
