Back to questions

Say you’re rolling a fair six-sided die. What is the expected number of rolls until you get two consecutive 5s?

This is the same question as problem #14 in the Statistics Chapter of Ace the Data Science Interview!

This question is similar in methodology to our All Six Sides problem. If this question feels overwhelming, we recommend trying the other one first!

Let *X* be the number of rolls until two consecutive 5s, and *Y* denote the event that a 5 was just rolled.

Conditioning on *Y*, we know that either we just rolled a 5 so we have just one more more 5 to roll, or we rolled some other number and now need to star over after having rolled once:

$E[X] = \frac{1}{6}(1+E[X|Y]) + \frac{5}{6}(1+E[X])$

Note that we have the following:

$E[X|Y] = \frac{1}{6}(1) + \frac{5}{6}(1+E[X])$

Plugging the results in yields an expected value of 42 rolls:

$E[X] = 42$