I am trying to calculate the expected number of rolls of a 6-sided die before getting a 2 followed immediately by a 3. Here's my solution,
Let the $E[N] = x$,
$x = \frac{1}{36}\left[ 2 + (1+1+x-1) + 4(x+2) \right] + \frac{30}{36}[x+1]$.
The first term is from the cases (1st toss, 2nd toss): (2,3), (2,2), (2, 1/4/5/6), and the second term is from when 1st toss is not a 2. This equation leads to x = 41. But, this is the wrong answer. The correct answer is 42. I think the mistake is in the $(1+1+x-1)$ term, but I am not sure why. I found a solution on the internet which says that this term is simply $(x+2)$. This doesn't make sense because $x$ is the unconditional expectation, whereas once we see that the 2nd toss is also a 2, there is obviously less number of rolls required to get a pattern of $23$. Can someone please explain this?
Let $A$ be the expected number of still needed rolls continuing from a state that has not yet made any progress towards ending the chain, either as a result of having just rolled a number which is not a $2$ and having not just ended, or as a result of having just started the game. Let $B$ be the expected number of still needed rolls from the state that you have just recently rolled a $2$.
You have that $A=\frac{5}{6}(1+A)+\frac{1}{6}(1+B)$ and that $B=\frac{1}{6}(1)+\frac{1}{6}(1+B)+\frac{4}{6}(1+A)$
The first coming from the observation that while at the starting position, you either effectively remain at the starting position having rolled anything except a $2$ and then still need an additional $A$ expected rolls in addition to the roll(s) you've already made. For the second, you can either go from the second state to the winning end state, stay in the second state, or go back to the first.
Solving gives $A=36$ and $B=30$, so the answer to your question is $36$
Since there remains confusion, here is a quick and dirty javascript simulation, performing the experiment $100000$ times, resetting between each attempt. Running the simulation confirms the result to be near $36$