I'm faced with the following problem:
Let $X$ be the number of times that we need to toss a coin until $r$ heads are obtained. Find the distribution and the expectation of $X$, if the probability of the coin landing heads is $p$.
I tried doing it this way:
If we require $n$ tosses to get $r$ heads, then in the first $n-1$ tosses we had $r-1$ heads and $n-r$ tails and the $n$th toss was heads. $$P(X=n) = \binom{n-1}{r-1} \cdot(1-p)^{n-r} \cdot p^{r-1} \cdot p$$
Is this a geometric distribution or some extension? I am sure I can wrangle that formula to give me the expectation after a lot of manipulation, but I was wondering if there was a way to massage it into a known expectation.
Your formula looks right. This is the negative binomial distribution (shifted by adding $r$, since you are counting the total number of tosses rather than the number of tails).
An easy way to get the expectation is that you are tossing coins until you get one head, and repeating $r$ times, so the expectation is just $r$ times that for one head (which is a geometric distribution).