# create function that behaves like continuedFraction [duplicate]

I'm just starting to learn Mathematica and I got stuck at this question. This a noob question but please help.

I need to define a function named continuedFraction that takes user input of type list as this continuedFraction[{a,b,c,d}] that will output

a / (1 + b/ (1 + c/ (1 + d)))


this is just any other continued fraction like on this page http://mathworld.wolfram.com/ContinuedFraction.html

what I had done so far after 383 inputs in notebook (now you know how hard this is for me)

fx[x_] := Fold[x/(1 + #) &, x, {a, b, c,}]

fx[{a, b, c, e}]

{a/(1 + a/(1 + a/(1 + a/(1 + a)))),
b/(1 + b/(1 + b/(1 + b/(1 + b)))),
c/(1 + c/(1 + c/(1 + c/(1 + c)))),
e/(1 + e/(1 + e/(1 + e/(1 + e))))}


which is of course, not the correct answer. ps: this is under functional programming-> pure function and a hint to use Fold.

-

## marked as duplicate by J. M.♦May 21 '13 at 14:43

Why not use FromContinuedFraction? – Michael E2 May 21 '13 at 14:16
because I am asked to create a function of my own definition. – momokjaaaaa May 21 '13 at 15:20

You're getting close. (Fold is an excellent choice.) Try:
f[x_List] := Fold[#2/(1 + #) &, 0, Reverse@x]

a/(1 + b/(1 + c/(1 + d)))