Find probability using geometric distribution I wanted someone to check the solution of this problem (see Rice's book, problem 2.14)
Two boys play basketball in the following way. They take turns shooting and
stop when a basket is made. Player A goes first and has probability $p_1$ of making a basket on any throw. Player B, who shoots second, has probability $p_2$ of making a basket. The outcomes of the successive trials are assumed to be independent.
a. Find the frequency function for the total number of attempts.
b. What is the probability that player A wins?
My solution: 
a. suppose that they make $k$ attempts. Then the answer depends on parity of $k$. If $k=2n+1$ it means that first player made $n+1$ attempts and $n$ first attempts were unsuccessful, while the last one was successful (he made a basket). As for second player, he made $n$ unsuccessful attempts. 
Bot these probabilities are easily found by multiplication of respective probabilities for the first and second player. 
The case when $k$ is even is solved in a similar way.
b. According to part a., we know how to find the probability that the game is over at $2n+1$ attempt. Therefore we sum these probabilities over $n\in \mathbb{N}$. 
Is it correct? Would be appreciated for your tips!
 A: Nothing wrong with enumerating all the paths and then summing the probabilities.  Another approach, which is sometimes simpler algebraically, is to do it recursively:  
Let $P(p_1,p_2)$ be the probability A wins given the data you mention.  Let's say A takes one shot.  It goes in, with probability $p_1$ and misses with probability $1-p_1$  If it misses, you are in back at the start of a similar game...only now Player B shoots first and the probability that A wins from here is 1 - $P(p_2,p_1)$.  Thus $$P(p_1,p_2) = p_1 + (1-p_1)(1 - P(p_2,p_1))$$
A similar calculation shows that 
$$P(p_2,p_1) = p_2 + (1-p_2)(1 - P(p_1,p_2))$$
In this way we get two equations in two unknowns which can easily be solved to yield $$P(p_1,p_2) = \frac{p_1}{p_1-p_1p_2 + p_2}$$
(trusting that no algebraic error was made).  As a sanity check, if we assume both probabilities are $\frac 12$, as in the case of alternating coin tosses, then this becomes $\frac 23$ which is the familiar answer.
A: Odd number of attempts ending with success results that the first player wins with probability
$$p_1\sum_{n=0}^{\infty}[(1-p_1)(1-p_2)]^n=\frac{p_1}{p_1+p_2-p_1p_2}.$$
So, the probability that the second player wins is $1$ minus the probability above:
$$\frac{p_2(1-p_1)}{p_1+p_2-p_1p_2}.$$
Or, one can say that if the number of attempts ending with a success is even then the second player wins. The probability of this event is
$$p_2\sum_{n=1}^{\infty}(1-p_1)^n(1-p_2)^{n-1}=p_2(1-p_1)\sum_{n=0}^{\infty}[(1-p_1)(1-p_2)]^n=\frac{p_2(1-p_1)}{p_1+p_2-p_1p_2}.$$
