Relationship between pmf and cdf I have one problem about basic probability theory.

Let X be a random variable of the discrete type with pmf p(x) that is positive on the nonnegative integers and is equal to zero elsewhere. Show that 
$$
E(X) = \sum\limits_{x=0}^\infty [1-F(x)], 
$$
where F(x) is the cdf of X.

When I expand the right hand side (by substituting $F(x)$ with $p(1) + p(2) + ... + p(x)$), I can "see" that the right hand side turns out to be $1*p(1) + 2*p(2) + 3*p(3) + ... $ (which is exactly the expectation of X). However, I am having some trouble formalizing this idea (i.e., proving the equation above formally). 
Can someone please help me ?
Thanks.
 A: Let $f:\mathbb Z_{\geq0}^2\rightarrow\{0,1\}$ be prescribed by $\langle n,k\rangle\mapsto1$ if $k>n$ and $\langle n,k\rangle\mapsto0$ otherwise.
$$\sum_{n=0}^{\infty}(1-F(n))=\sum_{n=0}^{\infty}\sum_{k=0}^{\infty}p(k)f(n,k)=\sum_{k=0}^{\infty}\sum_{n=0}^{\infty}p(k)f(n,k)=\sum_{k=0}^{\infty}p(k)\sum_{n=0}^{\infty}f(n,k)=\sum_{k=0}^{\infty}p(k)k$$
A: There is a theorem called the Riemann Rearrangement Theorem that says that your rearragement of the infinite series is allowed (since it is absolutely convergent). Alternatively, Fubini's theorem allows the following to be done (where $p(\cdot)$ is the pmf of $X$):
\begin{align}
E(X) &= ∑_{n=0}^∞ n p(n) = ∑_{n=0}^∞ \left(∑_{m=0}^n 1\right) p(n) \\
&= {\sum\!\!\sum}_{\{(n,m) ∈ \mathbb{N}^2 : m<n\}}p(n) \\ &= ∑_{m=0}^∞ ∑_{n=m}^{∞} p(n) \\
&= ∑_{m=0}^∞ [1-F(m)]
\end{align}

For reference, I had to recall the following proof from my uni Probability Theory:
$$E(X) = ∫_Ω  X(ω) \ \text{d}P(ω) = ∫_Ω ∫_{\{ω:t<X(ω)\}} \ \text{d}t \ \text{d}P(ω) = ∫_{t=0}^∞ ∫_{\{X>t\}}\text{d}P \ \text{d}t= ∫_0^∞ P(X>t) dt $$
but if measure theory is foreign to you, you should ignore this.

If someone has a simpler theorem than Fubini to use, I would love to hear it!
