Pull constant out of summation In the solution of my homework there's this step that I don't understand:
$$\begin{align}\mathsf {Var}[X] & = \sum_{k=1}^{n}\dfrac{n(k-1)}{(n-k+1)^2}\\ &= n \sum_{k=1}^{n}\dfrac{(n-k)}{k^2}\\&= n^2 \sum_{k=1}^{n}\dfrac{1}{k^2}-n \sum_{k=1}^{^n}\dfrac{1}{k}\end{align}$$
I would have thought, that when I pull $n$ out of the $\sum$ that I'd just get:
$n\sum_{k=1}^n\frac{(k-1)}{(n-k+1)^2}$.
Also I don't understand the second line. Could someone please tell me what steps are missing and how they solved this? Thanks!
 A: They've just preformed the distribution and substitution at the same time rather than two steps.
$$\begin{align}\mathsf {Var}[X] & = \sum_{k=1}^{~~n}\dfrac{n(k-1)}{(n-k+1)^2} &&\text{as given}
\\ &= n\sum_{k=1}^n\dfrac{(k-1)}{(n-k+1)^2} &&\text{distribution}
\\ &= n \sum_{k=1}^{n}\dfrac{(n-k)}{k^2} && \text{substitution: } k\gets n-k+1 \\&= n \sum_{k=1}^{n}\dfrac{n}{k^2}-n \sum_{k=1}^{n}\dfrac{k}{k^2}&&\text{commutation and association}\\&= n^2 \sum_{k=1}^{n}\dfrac{1}{k^2}-n \sum_{k=1}^{n}\dfrac{1}{k}&&\text{distribution and rationalisation}\end{align}$$
A: Alternatively, note that the summation is reversed:
$$\begin{align}\color{red}{\mathsf {Var}[X]} & \color{red}{= \sum_{k=1}^{n}\dfrac{n(k-1)}{(n-k+1)^2}}\\ 
&=n\left(\frac{1-1}{n^2}+\frac{2-1}{(n-1)^2}+\frac{3-1}{(n-2)^2}+\cdots+\frac{n-2-1}{3^2}+\frac{n-1-1}{2^2}+\frac{n-1}{1^2}\right) \\
&=n\left(\frac{n-1}{1^2}+\frac{n-2}{2^2}+\frac{n-3}{3^2}+\cdots+\frac{2}{(n-2)^2}+\frac{1}{(n-1)^2}+\frac{0}{n^2}\right) \\
&\color{red}{=n \sum_{k=1}^{n}\dfrac{(n-k)}{k^2}}\\
&=n \sum_{k=1}^{n}\left(\dfrac{n}{k^2}-\frac{k}{k^2}\right)\\
&\color{red}{= n^2 \sum_{k=1}^{n}\dfrac{1}{k^2}-n \sum_{k=1}^{^n}\dfrac{1}{k}}.\end{align}$$
