An urn contains $n$ balls numbered $1,2, \ldots ,n$. We remove $k$ balls at random and add up their numbers. Find the mean and variance of the total.
Let $X_i$ to be the number shown in the $i$th ball. Then for each $i$ we have $$P(X_i = i) = \frac{1}{n},$$ We now remove $k$ balls from the urn. Define $T =$ the sum of the balls removed, that is, $$T = \sum_{i=1}^k X_i,$$ then $$E(T) = E\left(\sum_{i=1}^k X_i\right) = E(kX_1) = kE(X_1).$$ Now:
$$E(X_1) = \sum_{i = 1}^n i P(X_i = i) = \frac{1}{n}*\frac{n(n+1)}{2},$$ thus, $$E(T) = \frac{k(n+1)}{2}.$$ Now, the variance of $T$ is given by $$\text{Var}(T) = E(T^2) -\left(E(T)\right)^2 = E((kX_1)^2) -\left(E(kX_1)\right)^2,$$ but $$E((kX_1)^2) = k^2E(X_1^2) = \frac{k}{n}\sum_{i = 1}^n i^2 = \frac{k^2}{n}*\frac{n(n+1)(2n+1)}{6} = \frac{k^2(n+1)(2n+1)}{6},$$ and $$(E(T))^2 = \left(\frac{k(n+1)}{2}\right)^2.$$ Thus, $$\text{Var}(T) = \frac{k^2(n+1)(2n+1)}{6} - \left(\frac{k(n+1)}{2}\right)^2 = \frac{k^2(n+1)(n-1)}{12}.$$
However, the answer in the book if $$\text{Var}(T) = \frac{1}{12}(n+1)k(n-k).$$
My question is if i am correct and the book gives an error or I am missing something.
As I mentioned in the comment, $E(T^2)\not=E((kX_1)^2)$. Instead, we have
\begin{align} E(T^2) & =E(\left(\sum_{i=1}^kX_i\right)^2)=E(\sum_{i=1}^kX_i^2+2\sum_{1\leq i<j\leq k} X_i X_j)\\ & = kE(X_1^2)+2\sum_{1\leq i<j\leq k}E(X_i X_j) \end{align} Some easy computation shows all $E(X_i X_j)$ are equal. So $E(T^2)=kE(X_1^2)+k(k-1)E(X_1 X_2)$.