TITLE: Probability of tossing a fair coin with at least $k$ consecutive heads
QUESTION [19 upvotes]: Tossing a fair coin for $N$ times and we get a result series as $HTHTHHTT\dots~$, Here '$H$' denotes 'head'  and '$T$' denotes 'tail' for a specific tossing each time.
What is the probability that the length of the longest streak of consecutive heads is greater than or equal to $k$? (that is we have a $HHHH\dots~$, which is the substring of our tossing result, and whose length is greater than or equal to $k$)
I came up with a recursive solution (though not quite sure), but cannot find a closed form solution.
Here is my solution.
Denote $P(N,k)$ as the probability for tossing the coin $N$ times, and the longest continuous heads is greater or equal than $k$.
Then (For $N>k$)
$$
P(N,k)=P(N-1,k)+\Big(1-P(N-k-1,k)\Big)\left(\frac{1}{2}\right)^{k+1}  
$$

REPLY [2 votes]: Feller considers this problem in section XIII.7 of An Introduction to Probability Theory and Its Applications, Volume 1, Third Edition.  He shows that the probability of having no run of length $k$ in $N$ throws is asymptotic to
$$\frac{1-(1/2)\;x}{(k + 1 - kx)\; (1/2)} \cdot \frac{1}{x^{N+1}}$$
where $x$ is the least positive root of $$1 - x +(1/2)^{k+1} x^{k+1} = 0$$
(I have changed Feller's notation to agree with the problem statement and have only considered the case of a fair coin; Feller considers the more general case of a biased coin.  For more information see equation 7.11, p. 325 in the referenced document.)