In this question we are being asked to derive the probability mass function for the geometric random variable. This mass function
is given at the top of this page in the short description of the geometric random variable. One way to answer this question would
thus be to explain why the experiment described in the question can be modelled using a geometric random variable. Another way
involves carefully thinking about the process of tossing a coin till you get a head. Lets suppose that you want the probability that
you get a head on the first flip. This is given by:
$$
P(X=1) = p
$$
which we are told in the question. Now suppose that you want the first head on the second flip. This implies that the first toss of the
coin gives tails. The probability of getting tails on this first flip is $(1-p)$ and the probability of getting heads on the second flip
is $p$. Furthermore, the outcome of any toss of the coin is independent of any other and as such we can get the probability of both these
events by multiplying. As such:
$$
P(X=2) = (1-p)p
$$
Now suppose we want the probability that $X=3$. To get $X=3$ we need to get a tails, followed by tails again followed by heads. As these
three outcomes are indepdent the probability of this sequence is:
$$
P(X=3) = (1-p)^2 p
$$
We can see the following pattern emerging here:
$$
P(X=n) = (1-p)^{n-1} p
$$
and hopefully it is clear why from the logic given in the previous paragraphs.
In the second part of the question we are asked to prove that:
$$
\sum_{n=1}^\infty P(X=n) = 1
$$
In this question this means manipulating the following series as follows
$$
\sum_{n=1}^\infty (1-p)^{n-1} p = p \sum_{n=1}^\infty (1-p)^{n-1}
$$
We now replace $n$ in the summation with $k=n-1$. This gives us:
$$
p \sum_{n=1}^\infty (1-p)^{n-1} = p \sum_{k=0}^\infty (1-p)^{k}
$$
Notice the change in the lower limit for the summation here. We now exploit the fact that the summation here is a geometric series
and note that:
$$
\sum_{k=0}^\infty (1-p)^{k} = \frac{1}{1-(1-p)} \qquad \textrm{if} \quad (1-p)<1
$$
The last inequality here, $(1-p)<1$, most definitely holds (as $p$ is a probability) so we can thus write:
$$
p \sum_{k=0}^\infty (1-p)^{k} = p \frac{1}{1-(1-p)} = \frac{p}{p} = 1
$$