An urn contains $i$ white balls and $(3-i)$ black balls. Let $T$ be the time there are only white balls left in the urn. Find $E[T]$.
At each time step we choose a ball at random and replace with a white ball.
So I tried to find a pattern:
if $i = 3$ the $E[T] = 0$ trivially,
if $i = 2$ then $E[T] = \frac{1}{3}\cdot 1 + \frac{2}{3}(1 + E[T]) \implies E[T] = 3$
If $i = 1$ then we have $E[T] = \frac{1}{3}(1+E[T]) + \frac{2}{3}(1+E[T\mid i = 2]) \implies E[T] = 12$
And lastly if $i = 0$ then $E[T] = 1(1+E[T \mid i = 1] \implies E[T] = 13$.
How ever I am not seeing the pattern of how to set this up:
Given $i$ I should be finding $E[T\mid i]$ which will be a function of $i$.
Since you asked for a general result, I'll try to get you started with that.
Suppose that there are $i$ white balls, and $n-i$ black balls in the urn.
Now in the case with $k$ black balls, there is a $\frac{k}{n}$ probability that a black ball is picked and replaced with a white ball. Further, with probability $\frac{n-k}{n}$, a white ball is picked and nothing changes.
So,
$$ \mathbb{E}[T | i] = 1 + \frac{n-i}{n}\mathbb{E}[T|i+1] + \frac{i}{n}\mathbb{E}[T | i] $$
Therefore the recurrence is,
$$ \mathbb{E}[T | i] = \frac{n}{n-i} + \mathbb{E}[T|i+1] $$
The base case for $\mathbb{E}[T | n] = 0$ and you want to find $\mathbb{E}[T | 0]$.
Can you take it from here?
Hint: Sum up the terms $\frac{n}{1} + \frac{n}{2} + \cdots + \frac{n}{n}$