Let $X$ be a positive continuous random variable with density function $f_X$ and cumulative distribution function $F_X$. By interchanging the double integral, show that for $p\in\mathbb{N}^+$ $$\mathbb{E}(X^p)=\int_{0}^{\infty} x^pf_X(x) \ dx=p\int_{0}^{\infty} (1-F_X(u))u^{p-1} \ du$$ where $x^p=\int_{0}^{x} pu^{p-1} \ du$.
My solution:
\begin{align} \mathbb{E}(X^p)&=\int_{0}^{\infty} x^pf_X(x) \ dx \\ &=\int_{0}^{\infty} \left(\int_{0}^{x} pu^{p-1} \ du\right)f_X(x) \ dx \\ &=\int_{0}^{\infty} f_X(x) \ dx \left(\int_{0}^{x} pu^{p-1}\ du\right) \ \\ &=\int_{0}^{\infty} pu^{p-1}\ du \left(\int_{u}^{\infty} f_X(x) \ dx\right) \ \ \ \ \ \text{(changing from u-simple to x-simple)} \ \\ &=p\int_{0}^{\infty} \left(1-F_X(u)\right)u^{p-1}\ du \end{align}
I am not so confident that the logic in my answer is correct, especially when I switch the order of integration. Is my working from the third to the forth line correct?