in order to get say r heads you need to flip the coin at least r times. thus for x>=r the number of possible ways to get r-1 heads in x-1 trials is (x-1)choose(r-1) without respect to order. on the xth trial we will get the rth success. thus since the trials are independent r of those trials have probability p for heads and x-r the remaining trials are all tails which have probability q = 1-p. we form the product of these total number of success and failures with the number of ways in which they may occur and we arrive at the negative binomial distribution. this distribution has a variance can you look it up and calculate it?