I am not sure to solve the following investment problem:
I have an investor which receives an income $I_n\ge 0$ at the start of year $n$. The investor chooses a proportion $p_n\in[0,1]$ of this in the stock market and consumes the remainder. At the start of the next year his income is of course $I_{n+1}=I_n+p_nI_nX_n$, where $X_n>0$ is the retrn on the stock market in year $n$ and is IID with mean $\mu$.
The investor now chooses $p_n$ to maximise $\mathbb E[\sum_{n=0}^{N-1}(1-p_n)I_n+I_N]$
This equation obviously represents the consumption over $N$ years, which the investor wants to maximise.
My solution: Let $F_s(i)$ be the maximal reward obtainable in state $i$ when there is time $s=N-t$ to go, then the dynamic equation is $F_s(i)=\max_p[(1-p)i+F_{s-1}(i+piX)]$ with $F_0(i)=0$ because at time $N$ there is no consumption.
Now $F_1(i)=i, F_2(i)=\max[(1-p)i+i+piX]=\max[2i,i+piX]=i\max[2,1+pX]=i\rho_2$
There I get by induction $F_s(i)=i\rho_s$
How should the investor now choose his strategy? I am almost done but I do not see thr last crucial step.
For the last two years you want to maximise the expectation of $$I_N+I_{N-1}(1-p_{N-1}) = I_{N-1}(2+p_{N-1}(X_{N-1}-1))$$ and the expectation is maximised: if $\mu=E[X_{N-1}] \gt 1$ when $p_{N-1}=1$; and if $\mu=E[X_{N-1}] \lt 1$ when $p_{N-1}=0$.
If you invest everything in the penultimate year then it seems obvious you will also invest everything in all previous years.
So let's look at the $\mu=E[X_{N-1}] \lt 1$ so $p_{N-1}=0$ and $I_N+I_{N-1}(1-p_{N-1}) = 2I_{N-1}$: then the last three years are about maximising the expectation of $$I_N+I_{N-1}(1-p_{N-1}) + I_{N-2}(1-p_{N-2}) = I_{N-2}[3+ p_{N-2}(2X_{N-2} -1)]$$ and whether optimal $p_{N-2}$ is $1$ or $0$ depends on whether $\mu \gt \frac12$ or $\mu \lt \frac12$.
Taking this back in a similar manner, the overall optimal strategy becomes clear:
let $p_n=1$ (i.e. invest everything) when $\mu \gt \frac{1}{N-n}$, i.e. when $n \lt N - \frac{1}{\mu}$
let $p_n=0$ (i.e. invest nothing) when $\mu \lt \frac{1}{N-n}$, i.e. when $n \gt N - \frac{1}{\mu}$.
You can choose any $p_n\in [0,1]$ (i.e. invest anything) when $\mu = \frac{1}{N-n}$, i.e. when $n = N - \frac{1}{\mu}$
I would not recommend this as a personal investment strategy. Risk should have an impact too.