Prove that $f$ is integrable if and only if $\sum^\infty_{n=1} \mu(\{x \in X : f(x) \ge n\}) < \infty$ Problem statement: Suppose that $\mu$ is a finite measure. Prove that a measurable, non-negative function $f$ is integrable if and only if $\sum^\infty_{n=1} \mu(\{x \in X : f(x) \ge n\}) < \infty$.
My attempt at a solution: Let $A_n = \{x \in X : f(x) \ge n\}$. To show that $\sum^\infty_{n=1} \mu (\{x \in X : f(x) \ge n\}) < \infty$ implies $f$ is integrable, the Borel Cantelli lemma tells us that almost all $x \in X$ belong to at most finitely many $A_n$. Thus, the set $\{x \in X : f(x) = \infty\}$ has measure $0$. Now, this, together with the fact that $\mu(X) < \infty$, should give us that $f$ is integrable, but I can't figure out how to prove that! It seems fairly obvious, but I can't figure out if it is then ok to say that $f$ is bounded almost everywhere? It seems like $f$ is then pointwise bounded, but I'm not sure if that means I can find some $M$ such that $f(x) \le M$ for all $x$.
For the reverse implication, I haven't come up with anything useful - I have been trying to show that the sequence of partial sums, $\sum^m_{n=1}\mu(A_n)$, is bounded, but I'm not sure how to do so.

If $f\ge 0$, you have
$$\int_\Omega f\, d\mu = \int_0^\infty |[f \geq x]| \, dx.$$
The function $x\mapsto |[f \geq x]|$ decreases to $0$ at $\infty$.
Can you see the rest?
