Suppose that $X$ is a discrete random variable taking values in $\{0,1,2,...\}$. Show that $E[X]=\sum^{\infty}_{k=0}{P(X>k)}$ Suppose that $X$ is a discrete random variable taking values in $\{0,1,2,...\}$. Show that $E[X]=\sum^{\infty}_{k=0}{P(X>k)}$

Absolutely lost. From my notes, we define $E[X]$ as follows
$E[X]=\sum^{\infty}_{k=1}{xP(X=k)}$
I am also unsure how to explictly write $\sum^{\infty}_{k=0}{P(X>k)}$. My intuitive understanding of $P(X>k)=\{$ probability of the event not occuring consequetively until $X=k\}$, i.e.
$P(X>k)=(1-P(0))(1-P(1))(1-P(2)) \dots (1-P(k-1))$
Or is it
$P(X>k)=1-[P(X=0)P(X=1) \dots P(X=k-1)$

To generalize, we have for an arbitrary random variable $X$ with $\mathbb P(X\geqslant 0)=1$,
$$ \mathbb E[X] = \int_0^\infty \mathbb P(X>t)\mathsf dt.$$
This follows from Fubini's theorem:
$$
\begin{align*}
\int_0^\infty \mathbb P(X>t)\mathsf dt &= 
\int_0^\infty \mathbb P(\omega\in\Omega: X(\omega)>t)\mathsf dt\\
&= \int_0^\infty \mathbb E[\mathbb I_{\{\omega\in\Omega :X(\omega)>t\}}]\mathsf dt\\
&= \int_0^\infty \int_\Omega \mathbb I_{\{\omega\in\Omega: X(\omega)>t\}}]\mathsf d\mathbb P\;\mathsf dt\\
&= \int_\Omega \int_0^{X(\omega)}\mathsf dt \mathsf\; d\mathbb P\\
&= \int_\Omega X\mathsf d\mathbb P\\
&= \mathbb E[X].
\end{align*}
$$
