My task is to compute given N - length binary series and P as a probability of 0 and (1-P) - probability of 1, expected number of consecutive occurence of 0 or 1 of k - length.

I know that when the probability of 0 and 1 is equal than

Expected number of series of 0 or 1 of k-lenth in n-length binary numbers is = (n-k+3)/2^(k+2).

But what the case when probability of 0 is for example (0.4) or any another?