# How to restrict the output values of a continued fraction?

I understand that a continued fraction of the form: $g(n_1,n_2,n_3,n_4,n_5,\ldots)= n_1 + \cfrac{1}{n_2 + \cfrac{1}{n_3 + \cfrac{1}{n_4 + \cfrac{1}{n_5+\cdots} } } }$

gives a unique irrational number for every sequence of natural numbers $(n_1, n_2,n_3,n_4,n_5,...)$. I wish to however, restrict the output values of this continued fraction to say, an interval $(a,b) \in \mathbb R$. Is it possible to do so by somehow tweaking the fraction?

• To an extent. By fixing the first few of your $n_j,$ but letting the rest vary, you restrict to an interval; If $n_1 = 1,$ the result is between $1$ and $2,$ for example. Nov 13, 2013 at 7:35

Yes. First of all, you need $\lfloor a\rfloor\le n_1\le \lfloor b\rfloor$. Then if $\lfloor a\rfloor< n_1< \lfloor b\rfloor$, no more restrictions apply. If $\lfloor a\rfloor= n_1< \lfloor b\rfloor$, recursively restrict $g(n_1,n_3,\ldots)$ to $(1,\frac1{a-n_1})$, if $\lfloor a\rfloor< n_1= \lfloor b\rfloor$ to $(\frac1{b-n_1},\infty)$ and if $\lfloor a\rfloor= n_1= \lfloor b\rfloor$ to $(\frac1{b-n_1},\frac1{a-n_1})$.
In principle, you have to watch out for the boundary points and I didn't describe how, but that does not matter not for "practical" purposes, especially, if $a,b$ are rational and you want to produce irrationals.