I don’t think you can do that in this case, since you don’t have enough boundary conditions.
I would be interested to see that function.
What I understand is that you allow positions n=1, \ldots, L, where L is the finish line, and I presume that if you are at n=1 and you try to go left, you stay at n=1 (i.e. you “bounce back” from a wall); in this way there are only a finite number of allowed positions n.
Your f(n) is the expected or mean time to hit the finish line L, starting from site n; this is a hitting time or (mean) first-passage time. In particular, f(L) = 0, since you’re already there.
If you write down all the equations for all values of n, you have a system of linear equations for the unknowns f(1), f(2), …, which you can solve using the \
operator.
A more general technique, in particular, for problems in which there are an infinite number of possible values of n, is to use a generating function, i.e. define
F(z) := \sum_n f(n) z^n
The recurrence relation, together with the boundary conditions, gives you an algebraic equation for F(z), which you can solve. You can then (sometimes) extract the results f(n) as the coefficient of z^n in the resulting expression.