I am trying to find a smart way to write the following fraction,

$$
F = \frac{a_1}{1+\frac{a_2}{1+\frac{a_3}{1+a_4}}}
$$

Here we can just take [itex]a_n= n[/itex] for simplicity. My fraction is in principle infinite, but I am trying to construct a function which can find [itex]F[/itex] for a given [itex]n[/itex] recursively. I haven't had much success. So far I have

which is the last term for a given [itex]n[/itex]. For do I propagate all the way up to [itex]a_1[/itex] then?