The function and its inverse are named longer and shorter. For example, expand Cot[1/4]-1 to one, two, three, and four terms: In[258]:= NestList[longer,Cot[1/4]-1,4] Out[258]= {-1+Cot[1/4], 2+1/1/(-3+Cot[1/4]), 2+1/(1+1/(3-Cot[1/4])/(-4+Cot[1/4])), 2+1/(1+1/(10+1/(4-Cot[1/4])/(-43+11 Cot[1/4]))), 2+1/(1+1/(10+1/(1+1/(43-11 Cot[1/4])/(-47+12 Cot[1/4]))))} Shorten the 3rd expansion by two: In[260]:= shorter[%[[4]],2] Out[260]= 2+1/1/(-3+Cot[1/4]) (In a notebook, these partial expansions display traditionally, but for a messy last term.) And now, ladies and gentlemen, here they are, Miss Jayne ... oops, no, here they are, the definitions of longer and shorter: Clear[longer]; longer[cf_, 0] := cf longer[x_?NumericQ, n_ : 1] := longer[HoldForm @@ {x}, n] longer[cf_, n_ : 1] := longer[cf /.HoldForm[r : Except[_Integer]] :> Floor[r] + 1/HoldForm @@ {Simplify@Together[1/Mod[r, 1]]}, n - 1] Clear[shorter]; shorter[cf_, 0] := cf shorter[cf_, n_ : 1] := shorter[cf /. (a_ : 0) + 1/HoldForm[r_] :> HoldForm @@ {1/Simplify[1/(a + 1/r)]}, n - 1] This continued fraction begins 2, 1, 10, 1, 18, 1, ... . Does it continue to grow by {8, 0}? Yes indeed, In[254]:= fromcf[{8 # + 2, 1}] Out[254]= -1 + Cot[1/4] where fromcf provides closed forms for a class of Hurwitz numbers: fromcf[pre_List : {}, {a___, (c1_ : 1)*# + c0_ : 0, b__}] := fromcf[Join[pre, {a, c0}], {b, a, c1*# + c0 + c1}] fromcf[pre_List : {}, {a___, (c1_ : 1) # + c0_ : 0}] := Simplify[FunctionExpand[ Block[{M = cfmat[{a}], A, B, C, D, det}, det = Det[{{A, B}, {C, D}} = M]; FromContinuedFraction[ Append[pre, A/(C + (det Hypergeometric0F1[1 + (B + C + A c0)/(A c1), det/( A^2 c1^2)])/( A c1 ((B + C + A c0)/(A c1))! Hypergeometric0F1Regularized[( B + C + A c0)/(A c1), det/(A^2 c1^2)]))]]]]] —rwg