# Expected Value of “Double” Random Variable

The question is as follows:

Consider the two uniform random variables $X$ on the interval $[0, n]$ and $Y$ on the interval $[0, X]$. What is the expected value of $Y$?

My idea was to find the expected value of $E[X]$ of $X$ and then let $Y$ be on the interval $[0, E[X]]$, but I fear this is horribly wrong. Can somebody please help?

$$\mathsf E(Y)~=~\mathsf E\big(\mathsf E(Y\mid X)\big)$$
Now you have been told that $Y\mid X ~\sim~\mathcal U[0;X]$ and $X\sim\mathcal U[0;n]$, so you can take it from here.
\begin{align}\mathsf E(Y) ~&=~ \mathsf E( X/2) \\[1ex] &= n/4\end{align}