TITLE: Rolling a $6$-sided dice indefinitely until lower than the previous throw
QUESTION [12 upvotes]: You will play a game with a fair 6-sided die. 
You will throw the die and as long as the result of the throw is greater than or equal to the previous throw, you will continue throwing. If the throw is lower than the previous one, you will stop and get as many points as the sum of all throws, including the last one. 
For example, if you get 2, 5, 5, and 3 as a result of 4 throws, the game will end with 15 points.
What is the expected value of the points you will get at the end of the game?

REPLY [3 votes]: Here is  an answer using  generating functions where we  demonstrate a
variety of relevant  techniques. Suppose the die has $n$  sides and we
classify  by  $q$,  the  last  nondecreasing  value  seen  before  the
decreasing value that  ends the game, so $2\le q\le  n.$ Using $x$ for
the number of points and $z$ for the number of rolls we obtain
$$G_q(z, x) = 
\left(\prod_{p=1}^{q-1} (1 + x^p z + x^{2p} z^2 + \cdots)\right)
\\ \times (x^q z + x^{2q} z^2 + \cdots)
(x^{q-1} z + x^{q-2} z + \cdots + x z).$$
This is
$$G_q(z, x) = \left(\prod_{p=1}^{q-1} \frac{1}{1-x^p z}\right)
\frac{x^q z}{1-x^q z} (x^{q-1}+\cdots+x) z
\\ = z^2 \left(\prod_{p=1}^{q} \frac{1}{1-x^p z}\right)
(x^{2q-1}+\cdots+x^{q+1}).$$
Introducing 
$$G(z, x) = \sum_{q=2}^n G_q(z, x)$$
the desired quantity is given by
$$\left. \frac{\partial}{\partial x} G(z, x) 
\right|_{x=1, \; z=1/n.}$$
Differentiate for the expected number of points:
$$z^2 \left(\prod_{p=1}^{q} \frac{1}{1-x^p z}\right)
\left(\sum_{p=1}^q \frac{p x^{p-1} z}{1-x^pz} \right)
(x^{2q-1}+\cdots+x^{q+1}) 
\\ + z^2 \left(\prod_{p=1}^{q} \frac{1}{1-x^p z}\right)
((2q-1) x^{2q-2}+\cdots+(q+1)x^{q}).$$
Set $x=1$ to find
$$z^2 \left(\prod_{p=1}^{q} \frac{1}{1-z}\right)
 \left(\sum_{p=1}^q \frac{pz}{1-z}\right) (q-1)
\\ + z^2 \left(\prod_{p=1}^{q} \frac{1}{1-z}\right)
\left(\frac{1}{2} (2q-1)(2q) - \frac{1}{2} q(q+1)\right).$$
Now
$$ \frac{1}{n^2} \prod_{p=1}^q \frac{1}{1-1/n}
=  \frac{1}{n^2} \prod_{p=1}^q \frac{n}{n-1}  
= \frac{n^{q-2}}{(n-1)^q}$$
and we obtain
$$\frac{n^{q-2}}{(n-1)^q} 
\left((q-1) \frac{1/n}{1-1/n} \frac{1}{2} q(q+1)
+ \frac{3}{2} q (q-1)\right).$$
Summing the contributions we get
$$\sum_{q=2}^n \frac{n^{q-2}}{(n-1)^q} 
\left(\frac{1}{2} \frac{1}{n-1} (q-1) q (q+1)
+ \frac{3}{2} q (q-1)\right).$$
The first of these is
$$\frac{3}{(n-1)^3} [w^{n-2}] \frac{1}{1-w}
\sum_{q\ge 0} \frac{n^q}{(n-1)^q} w^q {q+3\choose 3}
\\ = \frac{3}{(n-1)^3} [w^{n-2}] \frac{1}{1-w}
\frac{1}{(1-wn/(n-1))^4}.$$
The second is
$$\frac{3}{(n-1)^2} [w^{n-2}] \frac{1}{1-w}
\sum_{q\ge 0} \frac{n^q}{(n-1)^q} w^q {q+2\choose 2}
\\ = \frac{3}{(n-1)^2} [w^{n-2}] \frac{1}{1-w}
\frac{1}{(1-wn/(n-1))^3}.$$
Adding we find
$$\frac{3}{(n-1)^3} [w^{n-2}] \frac{1}{1-w}
\frac{1+(n-1)(1-wn/(n-1))}{(1-wn/(n-1))^4}
\\ = \frac{3}{(n-1)^3} [w^{n-2}] \frac{1}{1-w}
\frac{1+(n-1)-wn}{(1-wn/(n-1))^4}
\\ = \frac{3n}{(n-1)^3} [w^{n-2}]
\frac{1}{(1-wn/(n-1))^4}.$$
Extracting the coefficient we obtain
$$\frac{3n}{(n-1)^3} {n-2+3\choose 3} 
\frac{n^{n-2}}{(n-1)^{n-2}}
= \frac{1}{2} (n+1) n (n-1) \frac{n^{n-1}}{(n-1)^{n+1}}.$$
The result is the following closed form:
$$\bbox[5px,border:2px solid #00A000]{
\frac{1}{2} (n+1) \frac{n^n}{(n-1)^n}.}$$
This will produce 
$${\frac {163296}{15625}}$$
for $n=6,$ confirming the accepted answer. 
Observe that the above uses pen-and-paper type manipulations only.