How to find PMF A coin with probability p of heads is tossed until the first head occurs. It is then tossed some more until the first (subsequent) tail occurs. Let X be the total number of tosses required.
Find the pmf of X.
I am confused the PMF of X is joint by my assumption. I let X1 be the event gets first head
 A: We need $0\lt p\lt 1$.
It is clear that always $X\ge 2$. The event $X=n$ can happen in various ways:
Maybe the first head occurs on the first toss, and the next subsequent tail happens $n-1$ tosses after the first head. The probability of this is $p\cdot p^{n-2}(1-p)$. 
Maybe the first head occurs on the second toss, and the next subsequent tails happens $n-2$ tosses after the first head. The probability of this is $(1-p)pp^{n-3}(1-p)$.
Maybe the first head occurs on the third toss, and the next subsequent tails happens $n-3$ tosses after the first head. The probability of this is $(1-p)^2pp^{n-4}(1-p)$.
And so on. The last case is where the first head occurs on the $(n-1)$-th toss, and is followed immediately by a tail. The probability is $(1-p)^{n-2}p(1-p)$.
The sum is 
$$p(1-p)\left(p^{n-2}+p^{n-3}(1-p)+p^{n-4}(1-p)^2+\cdots +(1-p)^{n-2}\right).$$
The sum can be simplified. Special care must be taken when $p=\frac{1}{2}$. But if $p\ne 0$, $1$, or $\frac{1}{2}$ then 
$$\Pr(X=n)=p(1-p)\frac{p^{n-1}-(1-p)^{n-1}}{2p-1}.$$
The expectation of $X$ is much simpler. For $X=Y+Z$, where $Y$ is the waiting time until the first head, and $Z$ is the waiting time between the first head and the next tail after that. Each of $Y$ and $Z$ has geometric distribution, with means $\frac{1}{p}$ and $\frac{1}{1-p}$ respectively. Thus by the linearity of expectation we have $E(X)=\frac{1}{p}+\frac{1}{1-p}$.
