For integer $n \geq 0$, suppose that $X$ takes on value $n$ with probability $p_n$ where the $p_n$'s are nonnegative numbers such that $\sum_{n=0}^\infty p_n = 1$. Note that we don't assume that all the $p_n$ are nonzero; in fact, in many cases of interest, $p_n = 0$ for all $n > M$ for some finite integer $M$. Be that as it may, notice that the graph of $1-F(x)$ is a descending staircase function having value $1$ for $x<0$, and value $1-p_0$ for $x\in [0,1)$, value $1-p_0-p_1$ for $x\in [1,2)$, value $1-p_0-p_1-p_2$ for $x\in [2,3)$, and so on. So, the area under the $1-F(x)$ staircase on the positive axis is the sum of the areas of rectangles of base $1$ and heights
$$\begin{array}{lclclclclcl}1-p_0 &= &p_1&+&p_2&+&p_3&+&p_4&+&\cdots\\
1-p_0-p_1&= &&&p_2&+&p_3&+&p_4&+&\cdots\\
1-p_0-p_1-p_2&= &&&&&p_3&+&p_4&+&\cdots\\
\vdots \qquad \ddots & \vdots
\end{array}$$
Instead of adding by rows in the above table, if we add by columns to calculate the total area under $1-F(x)$, we see that
$$\int_0^\infty [1-F(x)]\,\mathrm dx = \sum_{n=1}^\infty n\cdot p_n = \sum_{n=0}^\infty n\cdot p_n = E[X].$$
So if we are agreed that $E[X]=\int_0^\infty P(X>x)\,\mathrm dx$ holds for any nonnegative random variable (not just integer-valued ones), it holds for $Y=X^n$ also and so we have
\begin{align}
E[Y] &= \int_0^\infty P(Y>y)\,\mathrm dy\\
&= \int_0^\infty P(X^n>y)\,\mathrm dy\\
&= \int_0^\infty P(X>y^{\frac 1n})\,\mathrm dy.
\end{align}
Now make a change of variables in that last integral by setting
$y^{\frac 1n} = x, \frac 1n y^{\frac 1n-1}\,\mathrm dy = \mathrm dx$, that is, $\mathrm dy = n x^{n-1}\mathrm dx$ to get
$$E[X^n] = \int_0^\infty n x^{n-1}P(X>x) \,\mathrm dx.$$