De Mere's Martingales In a casino, a player plays fair a game. If he bets $ k $ in one hand in that game, then he wins $ 2k$ with
probability $0.5$, but gets $0$ with probability $0.5$. He adopts the following strategy. He bets $1$ in the
first hand. If this first bet is lost he then bets $2$ at the second hand. If he loses his first $n$ bets, he
bets $2^n$ at the $(n + 1)$-th hand. Moreover, as soon as the player wins one bet, he stops playing (or
equivalently, after he wins a bet, he bets $0$ on every subsequential hand). Denote by $X_n$ the net profit
of the player just after the nth game, and $X_0 = 0$.
(i) Show that $(X_n)_{n≥0}$ is a martingale.
(ii) Show that game ends in a finite time almost surely.
(iii) Calculate the expected time until the gambler stops betting.
(iv) Calculate the net profit of the gambler at the time when the gambler stops betting.
(v) Calculate the expected value of the gambler’s maximum loss during the game.
My approach: Consider $Y_n$ to be i.i.d $Ber(0.5)$, $Y_n = 1$(win a bet) with probability $0.5$ and $Y_n = -1$(lose a bet) with probability $0.5$. Let $Y_n$ denote the outcome of $n$-th bet. The stopping time is defined as
$T = \inf\{ k: Y_k = 1\}$. Then,
$X_k = \sum_{i = 1}^{k}(2^{i}-2^{i-1})Y_i $. Is this definition of $X_k$ correct.  

For each $n\geqslant 0$ we have
$$X_{n+1} = X_n + 2^{n+1}Y_n.$$ Clearly $\mathbb E[X_0]=0$, and hence $$\mathbb E[X_{n+1}] = \mathbb E[X_n] + 2^{n+1}\mathbb E[Y_n] = \mathbb E[X_n].$$ Therefore $\mathbb E[X_n]=0$ for all $n$. Further, 
\begin{align}
\mathbb E[X_{n+1}\mid \mathcal F_n] &= \mathbb E[X_n + 2^{n+1}Y_n\mid\mathcal F_n]\\
&= X_n + \mathbb E[2^{n+1}Y_n]\\
&= X_n,
\end{align}
so that $\{X_n\}$ is a martingale.
We have $\mathbb P(T=n) = \left(\frac12\right)^n$ for $n\geqslant 1$, so $$\mathbb P(T=\infty) = 1-\sum_{n=1}^\infty \mathbb P(T=n) = 1 - \sum_{n=1}^\infty \left(\frac12\right)^n = 0,$$ and therefore the game ends in a finite time almost surely.
It is straightforward to see that the expected time until the gambler stops betting is $$\mathbb E[T] = \frac1{1/2}=2. $$
The net profit of the gambler at the time when the gambler stops betting is $$X_T=X_{T-1} +2^T. $$ Now, $Y_i=0$ for $i<T$, so
$$X_T = -\sum_{i=1}^{T-1}2^i +2^T=1.$$
The gambler's maximum loss $L$ is in bet $T-1$, so the expected maximum loss is given by
\begin{align}
\mathbb E[L] &= \mathbb E\left[2^{T-1} \right]\\
&= \sum_{n=1}^\infty 2^{n-1}\mathbb P(T=n)\\
&= \sum_{n=1}^\infty 2^{n-1}\left(\frac12\right)^n\\
&= \sum_{n=1}^\infty \frac12 =\infty.
\end{align}
