Show that X has density $f(x)$. Let $$f(x)=60x^3(1-x)^2,\quad 0<x<1.$$
Let $U_1,U_2,...$ and $V_1,V_2,...$ i.i.d. random variables with distribution $U(0,1)$. We build a random variable X as follows: $$U_1\leq60V_1^3(1-V_1)^2/60=V_1^3(1-V_1)^2,$$
If thats not true, we try with $U_2$ and $V_2$:  
if $$U_2\leq V_2^3(1-V_2)^2,$$
then $X=V_2$.
If not, we try with $U_3$ and $V_3$, etc. Show that X has density $f(x)$.
It's from an old probability test and a have no idea how to start, could use some hints
 A: $\def\P{\mathbb P}$So let's first find the index used in defining $X$, that is define 
$$ T(\omega) := \min \left\{k\in \mathbb N \mid U_k(\omega) \le f\bigl(V_k(\omega)\bigr)/60\right\} $$
if this minimum exists $T(\omega) := \infty$ otherwise. Then $T \colon \Omega \to [0,\infty]$ is measurable. We have
\begin{align*}
  p &:= \P(U_k \le f(V_k)/60)\\
    &= \int_{[0,1]^2} \chi_{\{x \le f(y)/60\}} \,d(x,y)\\
    &= \int_0^1\int_0^1 \chi_{\{[0,f(y)/60]\}}(x)\, dx\, dy\\
    &= \int_0^1 \frac 1{60} f(y)\, dy\\
    &= \int_0^1 y^3(1-y)^2\, dy\\
    &= \frac 1{60} \left[ 10y^6 - 24y^5 + 15y^4\right]_0^1\\
    &= \frac 1{60}.
\end{align*}
We have therefore
\begin{align*}
  \P(T= k) &= \P\bigl(U_1 > f(V_1)/60, \ldots, U_{k-1} > f(V_{k-1})/60), U_k \le f(V_k)/60\bigr)\\
      &= \P(U_1 > f(V_1)/60)\cdots \P(U_{k-1} > f(V_{k-1})/60)\P(U_k \le f(V_k)/60)\\
      &= (1-p)^{k-1}p
\end{align*}
and hence $\P(T < \infty) = 1$. By definition, we have $X = U_T$ and hence, for $x \in (0,1)$:
\begin{align*}
  \P(X \le x) &= \P(U_T \le x)\\
     &= \sum_{k=1}^\infty \P(U_T \le x, T = k)\\
     &= \sum_{k=1}^\infty \P(U_k \le x, T=k)\\
     &= \sum_{k=1}^\infty \P(U_1 > f(V_1)/60, \ldots, U_{k-1} > f(V_{k-1})/60, U_k \le \min\{f(V_{k-1})/60, x\})\\
     &= \sum_{k=1}^\infty (1-p)^{k-1} \int_0^x f(y)/60 \, dy\\
     &= \frac 1{60p}\int_0^x f(y)\, dy\\
     &= \int_0^1 f(y)\, dy.
\end{align*}
That is, $X$ has density $f$.
