A measurable function equal to a countable sum of characteristic functions? A theorem in measure theory says that if $\mu$ is a measure on $X$ and $f : X
\rightarrow [ 0, \infty]$ is $\mu$-measurable, then there exists a sequence $(
A_k)_{k \in \mathbb{N}}$ of $\mu$-measurable sets in $X$ such that $$f =
\sum_{k = 1}^{\infty} \frac{1}{k} 1_{A_k}$$ where $1_{A_k} ( x) = 1$ if $x \in
A_k$ and 0 otherwise.
I am trying to understand the intuition of this result. If $X =\mathbb{R}$
and $f$ is continuous, then $f$ takes an uncountable number of values in its
range. How could that be given a countable sum and values?
 A: So the point of this is really an extension of the idea of Egyptian fractions. To get any positive real number, $x$, we need only take a (possibly) infinite subset of $\Bbb N$ so that the reciprocal sum adds to $x$ in the limit; it is easy to prove this is possible, but for completeness the argument goes as follows:  iteratively add reciprocals of all natural numbers until adding the next one would be bigger than $x$, then skip all of them until you can add another reciprocal and still be less than or equal to $x$. Since the harmonic series diverges, we can always go up as much as we want eventually, so the sequence converges to its least upper bound, which is $x$ by construction.

From here we just note that we can associate, to each real number $x\ge 0$ the set $S_x\subseteq\Bbb N$ consisting of all natural numbers $k$ that we added to get $x$. Associate the empty set to $0$ and $\Bbb N$ to $\infty$. Then define the sets $A_k$ to include all $x\in X$ such that the image $f(x)\in [0,\infty]$ such that $k\in S_{f(x)}$
By definition
$$f=\sum_{k=1}^\infty {1\over k}\mathbf{1}_{A_k}$$
Fun corollary:  any divergent sequence for which the terms go to $0$ would work just as well as the harmonic series, you just do the same procedure and define associated sets in the same fashion:  it's really quite neat!
