sorry, if I can just check - does that give the right answer?
E(x) is 1 / (1-q). Which gives E(x^2) = d/dq (q/(1-q)
= 1 / (1-q)^2 = 1/ p^2
I know the answer is (1+q)/p^2; so this looks wrong?
In case anyone is interested, I found this by finding E(X(X-1)) first which is markedly easier. You then take the approach suggested, except using a second derivative.