How can I prove $$E(X) =\int_{0}^{\infty} [1 - F_X(x)] dx$$ for a continuous variable X and for a discrete variable X the following holds
$$E(X) = \sum_{k=0}^{\infty} [1 - F_X(k)]$$
My idea is to use the fact that $$E(X) = \int_{-\infty}^{\infty} x f_X(x) dx $$ but then how can I continue? Do I need to "break the integral" into 2?