I was trying to solve this problem:
We roll a 6-sided die n times. What is the probability that all faces have appeared in order, in some six consecutive rolls (i.e., what is the probability that the subsequence 123456 appears among the n rolls)?
My immediate reflex was to use Markov chains, but I soon backed down because of how tedious the calculations seemed. I know that it's supposed to be the correct way to tackle it but I've tried something different that ended up being wrong and I'd really appreciate it if you could help pointing out my mistakes.
So I decided to count the number of sequences containing the subsequence 123456. Indeed, any sequence of $n$ numbers is equiprobable of probability $\frac{1}{6^n}$. When we consider such we can pick any of $n-5$ starting point for the subsequence 123456, the rest of the sequence doesn't matter and each term can be any number of $\left\{1,2,3,4,5,6\right\}$ so we've got $6^{n-6}$ ways to pick the remaining numbers. So following this reasoning, I would be tempted to say that the wanted probability is $\frac{(n-5)6^{n-6}}{6^n} = \frac{n-5}{6^6}$ which obviously doesn't make sense because I could take an $n$ that's strictly greater than $6^6$ and it would be a probability strictly greater than $1$...
I really struggle with combinatorics like that and I never know why my reasoning is wrong.
Let $p(n)$ be the probability of having 123456 in $n$ rolls. Then, we have the following recurrence by conditioning on the first time that the sequence appears.
For $\color{blue}{6\le n \le 11}$:
$$p(n)=\color{blue}{(n-5) \left ( \frac{1}{6} \right ) ^6}$$
For $\color{blue}{n \ge 12}$:
$$p(n)=(11-5) \left ( \frac{1}{6} \right )^6+\sum_{i=7}^{n-5}(1-p(i-1)) \left ( \frac{1}{6} \right ) ^6= \color{blue}{\left ( \frac{1}{6} \right ) ^6 \left [n-5-\sum_{i=6}^{n-6}p(i) \right ]}$$
The above can be used to efficiently compute the probability $p(n)$.
From the above, for $n \ge 12$, one can obtain another recurrence (obtained in another answer based on a different reasoning):
$$p(n)=p(n-1)+\left ( \frac{1}{6} \right ) ^6 \left [1-p(n-6) \right ]$$
as follows:
$$p(n)-p(n-1)=\left ( \frac{1}{6} \right ) ^6 \left [n-5-\sum_{i=6}^{n-6}p(i)- \left( (n-1)-5-\sum_{i=6}^{n-1-6}p(i) \right ) \right ]=\left ( \frac{1}{6} \right ) ^6 \left [1-p(n-6) \right ].$$
More interestingly, using the recurrence, the probability can be determined in each range $6k\le n < 6(k+1)$ for $k\in \mathbb N$. For $k=1$, $6\le n < 12$, we have $$p(n)=(n-5) \left ( \frac{1}{6} \right ) ^6.$$
Let us set $k=2$ and find the formula of $p(n)$ for $\color{blue}{12\le n < 18}$:
$$p(n)=\left ( \frac{1}{6} \right ) ^6 \left [n-5-\sum_{i=6}^{n-6}p(i) \right ]=\left ( \frac{1}{6} \right ) ^6 \left [n-5-\left ( \frac{1}{6} \right ) ^6\sum_{i=6}^{n-6}(i-5) \right ]=\color{blue}{\left ( \frac{1}{6} \right ) ^6 \left [n-5-\left ( \frac{1}{6} \right ) ^6\frac{(n-10)(n-11)}{2} \right ]}.$$
This can be similarly used to obtain the formula for $k=3$ (and the next values of $k$) as we have the formulas for $p(6), \dots, p(11)$ and $p(12), \dots, p(17)$.
This procedure reveals that for $6k\le n < 6(k+1)$ the probability $p(n)$ is a polynomial of max order $k$:
$$p(n)=a_0+a_1n+\dots+ a_k n^k.$$
We could also use inclusion-exclusion, but the result is complex (see the closed-form formula obtained in another answer).
I doubt that a simple formula can be presented for $p(n)$ for $6k\le n < 6(k+1)$ for any $k \in \mathbb N$.
Update 1:
I realized that for $\color{orange}{n \ge 12 }$, the following is a very good approximation of $p(n)$:
$$p(n)=\color{orange}{\left ( \frac{1}{6} \right ) ^6 \left [n-5-\left ( \frac{1}{6} \right ) ^6\frac{(n-10)(n-11)}{2} \right ]}.$$
For $\color{orange}{n \le 100}$, the maximum error is less than $\color{orange}{9.72195267432557\text{E-}10}$
For $\color{orange}{n \le 1000}$, the maximum error is less than $\color{orange}{1.55551907611573E\text{E-}6}$.
For $\color{orange}{n \le 10000}$, the maximum error is less than $\color{orange}{0.00154961233453441}$.
For example, for $n=100$, $p(100)$ is $\color{blue}{0.00203434079881172}$, while the approximate value from the above formula is $\color{orange}{0.00203433982661645}$.
As another example, for $n=10000$, $p(10000)$ is $\color{blue}{0.192855678224992}$, while the approximate value from the above formula is $\color{orange}{0.191306065890458}$.
Update 2:
Finally, using a numerical study, I could obtain $\color{red}{\text{the exact general formula}}$ of $p(n)$ for $6k\le n < 6(k+1)$ for any $k \in \mathbb N$:
$$p(n)=\left ( \frac{1}{6} \right ) ^6 (n-5) -\left ( \frac{1}{6} \right ) ^{2 \times 6}\frac{(n-10)(n-11)}{2!}+\left ( \frac{1}{6} \right ) ^{3 \times 6}\frac{(n-15)(n-16)(n-17)}{3!} \dots (-1)^{k-1}\left ( \frac{1}{6} \right ) ^{k \times 6}\frac{(n-(6k-k))\dots (n-(6k-1))}{k!}.$$
$$\fbox{$p(n)=\sum_{i=1}^{k} (-1)^{i-1}\left( \frac{1}{6} \right ) ^{6i}\,\frac{\prod_{j=1}^{i}(n-(6i-j))}{i!}, \quad 6k\le n < 6(k+1).$}$$
In fact, this could be aldo obtained from the formula given in another answer using inclusion-exclusion after some simplifications.