Using Nest to build continued fraction
This is what you need:
Nest[x/(1 + #) &, x, 3]
Try the following.
f = Replace[#, 1/a_ -> x/a] &;
g[n_Integer] := Map[f, Nest[1/(1 + #) &, x, n], Infinity] // f;
Let us check
g[5]
g[10]
Have fun!