# Show that if $X\ge 0$ , $E(X)\le \sum_{n=0}^{\infty}P(X>n)$

If $X$ is a random variable and also let $X\ge 0$.

I want to show $E(X)\le \sum_{n=0}^{\infty}P(X>n)$.

Define the sets $A_n=\{x\in \mathbb{R}:x>n\}$, for $n=0,1,2\dots$.
For any fixed $\omega$, let $n_0$ be the smallest integer such that $X(\omega)\leq n_0$. Since $X(\omega)\geq 0$, we have
$$X(\omega)\leq n_0 = \sum_{n=0}^{n_0} I_{A_n} (X(\omega)) = \sum_{n=0}^\infty I_{A_n} (X(\omega)) \, ,$$
$$\mathrm{E}[X]\leq \sum_{n=0}^\infty \mathrm{E}[I_{A_n} (X)]=\sum_{n=0}^\infty P(X>n) \, .$$