Expected Value dice rolling You roll a die until you get the number five. What is the expected value of the maximum roll you see(don't include 5, we only consider rolls upto and before the 5). I created a solution to this problem, although I am still confused because of the dependency on the number of rolls. Any commentary would be appreciated

Suppose that it takes $n$ rolls to see a 5. Then 
$E(n) = \frac{1}{6}^n \cdot 1 + \frac{1}{6} \cdot n \cdot \frac{2}{6}^{n-1} \cdot 2 + \frac{1}{6} \cdot n \cdot \frac{3}{6}^{n-1} \cdot 3 + \frac{1}{6} \cdot n \cdot \frac{4}{6}^{n-1} \cdot 4 + (1-\frac{5}{6}^n) \cdot 6$.
The probabilities in the expected value function are computed as the probability that number will be the highest out of n rolls. For instance for 2 being the highest roll, we have to have two appear in the sequence of $n$ rolls, and then have all the other rolls be two or less, which corresponds to probability $\frac{1}{6} \cdot n \cdot \frac{2}{6}^{n-1}$. Now my question is how this depends on the number of rolls. For the overall expected value do we simply use the expected number of flips to roll a five, which is six, and then plug 5 into the equation to get the overall expected value? (when I do I get 4.42)

(as another thought, should i integrate the expected value function from $n=0$ to $\infty$?)
Let's assume you have a five-sided die, with faces $\{1,2,3,4,6\}$.  You roll it $k$ times.  What is the expected value of the max roll? Well, it's going to depend on $k$.
\begin{equation}
P(max=1) = \frac{1}{5^k}
\end{equation}
\begin{equation}
P(max=2) = \left(\frac{2}{5}\right)^k - \frac{1}{5^k}
\end{equation}
\begin{equation}
P(max=3) = \left(\frac{3}{5}\right)^k - \left(\frac{2}{5}\right)^k
\end{equation}
\begin{equation}
P(max=4) = \left(\frac{4}{5}\right)^k - \left(\frac{3}{5}\right)^k
\end{equation}
\begin{equation}
P(max=6) = 1 - \left(\frac{4}{5}\right)^k
\end{equation}
\begin{equation}
E[max] = 6 - 2 \left(\frac{4}{5}\right)^k - \left(\frac{3}{5}\right)^k - \left(\frac{2}{5}\right)^k - \frac{1}{5^k}
\end{equation}
Basically, the probability that the $m$th highest value is the maximum is the probability that all the rolls were at most that large, minus the probability that all the rolls were smaller than that value.

Now, we want to sum over $k$, using the probability that the $k+1$st roll is a 5 and none of the others are.
\begin{equation}
E = \sum_{k=0}^\infty \left( 6 - 2 \left(\frac{4}{5}\right)^k - \left(\frac{3}{5}\right)^k - \left(\frac{2}{5}\right)^k - \frac{1}{5^k} \right) * \left( \frac{5}{6} \right)^k \frac{1}{6}
= \frac{1}{6} * \left( 6 * 6 - 2 * 3 - 2 - \frac{3}{2} - \frac{6}{5} \right) = \frac{1}{6} * ( 25.3 ) \approx 4.2167
\end{equation}
Let $P_k$ be the probability that the first instnace to see a 5 was the kth roll, then $E=\sum_{k=1}^\infty kP_k\ where\ P_k=\frac{1}{6} (\frac{5}{6})^{k-1}$