Using the information you gave, there are 2 key steps to do this.
Interest
So if we have $£x$, and we receive interest at a rate of $r$, we get $£x$ (our initial investment) + $£rx$ (the interest) (here we view the investment as a decimal).
So for example, if my bank was giving me $20\%$ interest, and I invest $£20$, then in total I would have
$£20 + £20\times0.2 = £24$.
An easier way to put this would be $£x(1+r)$.
Recurrences
We have that $a_n$ is the money from the $n-1$- th year along with interest, from above, we have that $$a_n = a_{n-1}(1+r).$$
Along with the initial condition $a_0 = P$, we can solve this.
One general way to solve recurrence relations, is to write them out until we see a pattern emerge.
So \begin{align}
a_n &= a_{n-1}(1+r)\\
&= a_{n-2}(1+r)^2\\
&\,\vdots\\
&= a_{1}(1+r)^{n-1}\\
&= a_0(1+r)^n\\
&= P(1+r)^n.
\end{align}
Thus we have solved the recurrence!
Recurrences with additional investment
What if I invested an additional $P$ each year? What is the recurrence equation and the formula? Is it $a_n = n P(1+r) + P$?
Not quite, let's apply the same technique. Each year, we would get interest and then also we would add in investment.
This makes it
$$a_n = a_{n-1}(1+r) + P.$$
By applying the same technique as above, we get that $$a_n = P \frac{(1+r)^{n+1} - 1}{r}.$$