1648. Shooting is carried out at a certain target until the first hit without limiting the number of shots. Find the mathematical expectation and variance of the number of shots fired, if the probability of hitting with each shot is the same and equal to $p$.
Solution. First, let's find the probability that the shooting ends with the $(n+1)$-th shot (the first $n$ shots missed, and the $(n+1)$-th shot hit). Since the probability of the product of independent events is equal to the product of their probabilities, the desired probability is

$$
q_{-n}^{q q} \ldots q p=q^{n} p
$$

where $q=1-p ; n=0,1,2, \ldots$

Let the random variable $X$ be the number of shots fired. Then

$$
E X=\sum_{n=0}^{\infty}(n+1) q^{n} p=p \sum_{n=0}^{\infty}(n+1) q^{n}=p S(q)
$$

where $S(q)=\sum_{n=0}^{\infty}(n+1) q^{n}$ is the sum of a power series with a radius of convergence equal to 1. Therefore, for $|q|<1$

$$
\int_{0}^{q} S(q) d q=\sum_{n=0}^{\infty} \int_{0}^{q}(n+1) q^{n} d q=\sum_{n=0}^{\infty}(n+1) \frac{q^{n+1}}{n+1}=\sum_{n=0}^{\infty} q^{n+1}=\frac{q}{1-q}
$$

From this, $S(q)=\left(\frac{q}{1-q}\right)^{\prime}=\frac{1}{(1-q)^{2}}=\frac{1}{p^{2}}$, and

$$
E X=p S(q)=p \cdot \frac{1}{p^{2}}=\frac{1}{p}
$$

Similarly, we find the variance of the random variable $X$:

$$
\begin{gathered}
D X=E X^{2}-(E X)^{2} ; E X^{2}=\sum_{n=0}^{\infty}(n+1)^{2} q^{n} p= \\
=p \sum_{n=0}^{\infty}(n+1)^{2} q^{n}=p L(q)
\end{gathered}
$$

where $L(q)$ is the sum of a power series with a radius of convergence equal to 1. For $|q|<1$

$\int_{0}^{q} L(q) d q=\sum_{n=0}^{\infty} \int_{0}^{q}(n+1)^{2} q^{n} d q=q \sum_{n=0}^{\infty}(n+1) q^{n}=q S(q)=\frac{q}{(1-q)^{2}}$.

Therefore, $L(q)=\left[\frac{q}{(1-q)^{2}}\right]^{\prime}=\frac{1+q}{(1-q)^{3}} ; E X^{2}=\frac{p(1+q)}{p^{8}}=$ $=\frac{1+q}{p^{2}} ; D X=\frac{1+q}{p^{2}}-\left(\frac{1}{p}\right)^{2}=\frac{q}{p^{2}}$.