latex in case i need it later

\begin{eqnarray*}

E(X^2) &=& \sum_{i=0}^n \left( i^2 \frac{n!}{i!(n-i)!} p^{i} (1-p)^{n-i}\right)\\

&& \text{note first term in sum is 0 and rewrite limit}\\

&=& \sum_{i=1}^n \left( i^2 \frac{n!}{i!(n-i)!} p^{i} (1-p)^{n-i}\right)\\

&=& np\sum_{i=1}^n \left( i \frac{(n-1)!}{(i-1)!(n-i)!} p^{i-1} (1-p)^{n-i}\right)\\

&& \text{let } j=i-1 \text{ , so }i=j+1\\

&=& np\sum_{j=0}^{n-1} \left( i \frac{(n-1)!}{(j)!(n-1-j)!} p^{j} (1-p)^{n-1-j}\right)\\

&=& np\sum_{j=0}^{n-1} \left( (j+1) \frac{(n-1)!}{(j)!(n-1-j)!} p^{j} (1-p)^{n-1-j}\right)\\

&=& np\sum_{j=0}^{n-1} \left( (j) \frac{(n-1)!}{(j)!(n-1-j)!} p^{j} (1-p)^{n-1-j}\right)+ np\sum_{j=0}^{n-1} \left( \frac{(n-1)!}{(j)!(n-1-j)!} p^{j} (1-p)^{n-1-j}\right)\\

&& \text{recognise right hand sum as PDF of Bi(n-1,p)}\\

&=& np\sum_{j=0}^{n-1} \left( (j) \frac{(n-1)!}{(j)!(n-1-j)!} p^{j} (1-p)^{n-1-j}\right)+ np \times 1\\

&& \text{recognise left hand sum as Expectation of Bi(n-1,p)}\\

&=& np\left((n-1)p \right)+ np \times 1\\

&=& np\left((n-1)p + 1 \right)

\end{eqnarray*}