Here is another way to obtain a set of recursive equations for determining Pn, the probability that there is a string of k consecutive heads in a sequence of n flips of a fair coin that comes up heads with probability p:
(a) Argue that, for k < n, there will be a string of k consecutive heads if either
1. There is a string of k consecutive heads within the first n − 1 flips, or
2. There is no string of k consecutive heads within the first n − k − 1 flips, flip n – k is a tail, and flips n − k + 1, . . . , n are all heads.
(b) Using the preceding, relate Pn to Pn−1. Starting with Pk = pk, the recursion can be used to obtain Pk+1, then Pk+1, and so on, up to Pn.