$L^p$-space and lebesgue measure I have some problems with the following task:
Show that $f\in\mathscr L^p(X,\mathbb R)$ iff $\sum_{n\in\mathbb Z}2^{np}\lambda(\{x\in X:|f(x)|\geq2^n\})<\infty$, for $X\in \mathscr B(\mathbb R^d)$ and $f:X\rightarrow \mathbb R$ measurable. $\lambda$ is the lebesgue measure on $\mathbb R^d$ and $p\in[1,\infty)$.
I tried to show "$\Leftarrow$" and I tried to write the sum as $\sum_{n=1}^\infty\frac{1}{2^{np}}\lambda(\{x\in X:|f(x)|\geq \frac{1}{2^n})+\sum_{n=1}^\infty 2^{np}\lambda(\{x\in X:|f(x)|\geq2^n\}+\lambda(\{x\in X:|f(x)|\geq 1\}$. I also know $\|f\|_p^p=\int_{0}^\infty \lambda(\{x\in X:|f(x)|\geq t\}pt^{p-1}dt$ but I don't know how to use this to show $\|f\|_p<\infty$.
Thanks for a hint.
 A: Note that $$ \sum_{n \in \mathbb Z} 2^{np} \lambda( \{ |f| \ge 2^n \}) = \sum_{n \in \mathbb Z} \int_{\mathbb R^d} 2^{np} 1_{\{|f| \ge 2^{n}\}}d\lambda = \int_{\mathbb R^d} \sum_{n \le [\log_2|f|]} 2^{np} d\lambda $$ $$= \int_{\mathbb R^d} \sum_{n \ge - [\log_2|f|]} (2^{-p})^nd\lambda = \int_{\mathbb R^d} \frac{1}{1-2^{-p}} 2^{p[\log_2|f|]}d\lambda.$$ Note that $\log_2|f| - 1\le[\log_2|f|] \le \log_2|f|$, hence the very last integral is bounded from below and above by some constants $c_p,C_p$ (depending only on $p$) times $\int_{\mathbb R^d}2^{p\log_2|f|}d\lambda = \int_{\mathbb R^d} |f|^pd\lambda$. We could interchange integral and the sum, since our function is non-negative (we're integrating $(n,x) \mapsto 2^{np} 1_{\{|f(x)| > 2^n\}}$ with respect to $\mu \otimes \lambda$, where $\mu$ is a counting measure on $\mathbb Z$, so we can use Fubinii/Tonelli theorem).
Long story short, if you have a condition involving multiple integrals (note that the sum and $\lambda(\cdot)$ are in fact integrals), it is always wise to at least try to change the order of integration, many times it is enough.
