Random variable $X$ has the probability density function \begin{equation*} f\left( x\right) =\left\{ \begin{array}{ccc} n\left( \frac{x}{\theta }\right) ^{n-1} & , & 0<x\leqslant \theta \\ n\left( \frac{1-x}{1-\theta }\right) ^{n-1} & , & \theta \leqslant x<1% \end{array}% \right. \end{equation*} show that if $k\in \mathbb{N}$ \begin{equation*} \mathrm{E}\left( X^{k}\right) =\frac{n\theta ^{k+1}}{n+k}+\sum% \limits_{i=0}^{k}\left( -1\right) ^{i}\binom{k}{k-i}\frac{n}{n+i}\left( 1-\theta \right) ^{i+1} \end{equation*}
It is easy to find the first term of $\mathrm{E}\left( X^{k}\right) $ but i couldn't find the second one. i think i have to use beta distribution properties. i tried to simulate the integral \begin{equation*} \int\nolimits_{\theta }^{1}nx^{k}\left( \frac{1-x}{1-\theta }\right) ^{n-1}% \mathrm{d}x \end{equation*} to beta pdf using $u=\frac{x-1}{\theta -1}$ transformation but i couldn't get a reasonable result. After this transformation is applied i have to find \begin{equation*} \int\nolimits_{0}^{1}u^{n-1}\left[ 1+u\left( \theta -1\right) \right] ^{k}% \mathrm{d}x \end{equation*} but i couldn't. Also I tried to use the equality \begin{equation*} x^{k}=1+\left( x-1\right) \sum\limits_{n=0}^{k-1}x^{n} \end{equation*} but i couldn't get the result.