Solution
= Solution
Differentiate the <probability generating function> to obtain
$$
G_X'(1)=\frac qp,\qquad G_X''(1)=\frac{2q^2}{p^2}.
$$
The first derivative is the <expected value>, and the second gives the <factorial moment> $\mathbb E[X(X-1)]$. Hence
$$
\boxed{\mathbb E X=\frac{1-p}{p},\qquad
\operatorname{Var}(X)=G_X''(1)+G_X'(1)-G_X'(1)^2
=\frac{1-p}{p^2}.}
$$
In particular, $\mathbb E[X^2]=q(2-p)/p^2$.