I am trying to understand one step in the proof of the Möbius inversion formula.
The theorem is
Let $f(n)$ and $g(n)$ be functions defined for every positive integer $n$ satisfying $$f(n) = \sum_{d|n}g(d)$$ Then, g satisfies $$g(n)=\sum_{d|n}\mu(d) f(\frac{n}{d})$$
The proof is as follows:
We have $$\sum_{d|n}\mu(d)f(\frac{n}{d}) = \sum_{d|n}\mu(\frac{n}{d})f(d) = \sum_{d|n}\mu(\frac{n}{d}) \sum_{d'|d}g(d') = \sum_{d'|n}g(d')\sum_{m|(n/d')}\mu(m)$$ Where in the last term, the inner sum on the right hand side is $0$ unless $d'=n$.
My question is: how do we get the last equation? I don't really understand how the author interchanges the summation signs. Thanks for any help!