Say I collect 40 perfectly random integers between 1 and 400. What's the chance that any integer is repeated consecutively six times in such a random draw?
What I'm looking for is the chance of sequences like [372, 193, 42, 42, 42, 42, 42, 42, 274, 42, 7, ...], [372, 193, 42, 42, 42, 42, 42, 42, 274, 242, 7, ...], or [372, 193, 42, 42, 42, 42, 42, 42, 42, 42, 42, ...] as they all fulfills what I'm looking for. As a counter example [372, 193, 42, 42, 42, 42, 42, 77, 274, 42, 7, ...] does not satisfy my conditions because the six 42's are not consecutively repeated.
The Birthday problem gives that it's an 87% chance that two of the 40 are the same number but I'm failing to go from that to calculating the chance of a certain integer consecutively repeating itself n number of times in the random collection.
You can use inclusion-exclusion to get bounds on this. For $A \subset [40]$ of length $6$, let $S_A$ be the event that all numbers in $A$ are the same. The probability $p$ that you want is then bounded by $$ \sum_A \Pr[S_A] - \sum_{A \neq B} \Pr[S_A \text{ and } S_B] \leq p \leq \sum_A \Pr[S_A]. $$ Since $\Pr[S_A] = 400^{-5}$, it is easily to calculate the upper bound: it is $$ \binom{40}{6} 400^{-5} \approx 0.000000375.$$ Calculating the lower bound is more messy so I'll leave it to you. My guess is that it will be pretty close to the upper bound. If it isn't, you can always take more terms in the inclusion-exclusion formula.