Odds of 3 identical digits in a row in a 6 digit number If I have a 6 digit random number what are the odds of me having 3 consecutive digits be identical?  examples $341117$ or $444628$
I thought of two ways to answer this and they give very different results. One (or both!) are incorrect.  Can someone explain to me what is wrong with the reasoning in the wrong one?
First approach:  There are 4 possible positions for the 3 identical digits, and at each position there are ten possibilities $(000, 111, 222....999)$. The remaining digits do not matter. So that sounds like out of the one million number combinations from 000000 all the way up to 999999 there are 40 ways this could happen, so this smells like 40 out of 1 million or one chance out of 25000. (and I think I now see a flaw in that reasoning)
Second approach (and now I realize, gives the right answer): For each of the first 4 digits it does not matter what value they have.  There is then a one in 100 chance the next two digits will be the same. so the odds of this happening are 4 times 1 in 100 or one chance in 25.
What I missed from the first approach is that for each set of three digits in a row, there are one thousand combinations for the other three digits, so for each of those 40 ways, there are actually 1000 possibilities (example 111432 and 111739 are two of the 1000 ways to have a 6 digit number starting with 111) . So 40,000 ways out of a million numbers is 1 in 25.
I guess this is not even a question anymore, but it was when I started writing, so I will share.
 A: Neither $1$ in $25$  nor $1$ in $25000$ is the correct probability.

To clarify: we are including leading zeroes in the six-digit sequence, so "$001234$" would be one possibility, even though that would typically be called a four-digit number.

Case 1: Sequences of the form AAAAAA, of which there are exactly $10$, one for each digit.
Case 2: Sequences of the form AAABBB, with A and B distinct. There are $10$ ways to choose the digit A, and for each of these, $9$ ways to choose the digit B. There are therefore $90$ such sequences.
Case 3: Sequences of the form XAAAYZ and XYAAAZ. Here, the XYZ need not be distinct digits, but they are not the same digit as A. There are $10$ ways to choose the digit A, and $9^3$ ways to choose the three other digits. There are therefore $7290$ sequences of the form XAAAYZ and $7290$ sequences of the form XYAAAZ, for a total of $14580$ sequences in this case.
Case 4: Sequences of the form AAAAXY, XAAAAY, and XYAAAA. Here, the XY need not be distinct digits, but they are not the same digit as A. There are $10$ ways to choose the digit A, and $9^2$ ways to choose the two other digits. There are therefore $810$ sequences in each of the three formats, for a total of $2430$ in this case.
Case 5: Sequences of the form AAAAAB and BAAAAA. There are $10$ ways to choose the digit A, and, for each of these, $9$ ways to choose the digit B. There are therefore $90$ sequences in each of the two formats, for a total of $180$ in this case.
Case 6: Sequences of the form AAAXYZ, with XYZ not all the same, and X not the same as A. There are $10$ ways to choose A, and given this, $9$ ways to choose X. YZ can be any of the $10^2$ possible two digit sequences, other than XX, so there are $10^2-1=99$ possibilities for YZ. This gives a total of $10\cdot 9 \cdot 99 = 8910$ sequences in this case.
Case 7: Sequences of the form XYZAAA, with XYZ not all the same, and Z not the same as A. The reasoning is the exact same as in Case 6, so we have $8910$ sequences.
Case 8: Sequences of the form AAAABA and ABAAAA. There are $10\cdot 9 = 90$ of each, for a total of $180$ sequences in this case.
Case 9: Sequences of the form XAAAYA and AXAAAY. Here, X and Y need not be distinct, but must be different from A. There are $10$ ways to choose A, and $9^2$ ways to choose X and Y. This gives $810$ sequences for each of the two formats, for a total of $1620$ sequences in this case.

Summing these nine cases gives a total of
$$10 + 90 + 14580 + 2430 + 180 + 8910  + 8910 + 180 + 1620 = 36910$$ sequences in which there's a digit repeat of length $\geq 3$.

Finally, the total number of six-digit sequences is $10^6$, so the probability of getting a digit repeat of length $\geq 3$ is $$\displaystyle\frac{36910}{1000000} \, = \, \boxed{3.691\%\,}$$
This is about $1$ in $27$.
A: This can be solved with a Markov chain with three states.  Take as start situation a single digit number and add another digit in each step of the Markov process.  The meaning of the three states is

*

*No three consecutive digits are equal and the last digit differs from the one before it.

*No three consecutive digits are equal but the last two digits are equal.

*There are three consecutive equal digits.

This Markov chain has the following transition matrix:
$$M = \begin{pmatrix}
\frac{9}{10} & \frac{9}{10} & 0 \\
\frac{1}{10} & 0 & 0 \\
0 & \frac{1}{10} & 1
\end{pmatrix}.$$
Then the question asks for the probability to reach state $3$ from state $1$ in five steps.  This probability is given by the lower left entry in $M^5$ (column one, row three).  A direct matrix computation shows that this probability equals $0.03691$.
Alternatively, a linear recursion can be used to compute the probablity $p_n$ of three consecutive equal digits in an $n$-digit number.  This probability $p_n$ equals the lower left entry of the matrix $M^{n-1}$. The characteristic polynomial of $M$ is $$\det(\lambda I - M) = \lambda^3 - \frac{19}{10}\lambda^2 + \frac{81}{100}\lambda + \frac{9}{100}$$
and by the Cayley-Hamilton theorem this leads to the following linear recursion for $p_n$:
$$p_{n+3} = \frac{19}{10}p_{n+2} - \frac{81}{100} p_{n+1} - \frac{9}{100} p_n.$$
Now it is an easy calculation to compute the sequence $p_1, p_2, \ldots$ starting from the first three values $0,\ 0,\ 0.01$:
$$0,\ 0,\ 0.01,\ 0.019,\ 0.028,\ 0.03691,\ 0.045739, \ldots $$
