The hardest part about this exercise is getting the spacing right.
First, you will want to align the 1
above the q_i
. For this, you will need measure the width of every q_i
and place the 1
manually. A helper macro is convenient:
\def\leftfrac#1#2#3#4{\frac % {#1} {#2#3#4}
{\setbox0=\hbox{$\displaystyle#2$}
\hbox to\wd0{\hfil$\displaystyle#1$\hfil}\hfill}
{\displaystyle#2#3#4}}
\[ \leftfrac 1 {q_i} + 1 \]

The next step is continuing the fraction without extending the rule. This is the trickiest part, because we want to preserve both the spacing between the rule and the 1
and the proper binary spacing around the +
, while retaining the overall width and height of the fraction.
We solve this problem by following each fraction by two skips, both equalling the width of the part after q_i
, but the first negative and the second positive. Then, inside the continued fraction, if we can somehow move out the second skip and place it behind the fraction, we should have all we need.
Expanding the previous macro:
\def\leftfrac#1#2#3#4{% #1 \over #2 #3 #4
% measure partial and full denominator
\setbox0=\hbox{$\displaystyle#2$}
\setbox2=\hbox{$\displaystyle#2#3#4$}
\frac
% a strut in the numerator ensures proper spacing
{\hbox to\wd0{\hfil
$\displaystyle
\strut #1 $
\hfil} \hfill}
% move the last skip of the denominator out of the fraction
{\displaystyle#2#3#4
\dimen0=\lastskip \unskip
\expandafter\egroup
\expandafter\hskip
\the\dimen0
\bgroup}
% two opposite skips (will cancel unless interfered with)
\hskip\dimexpr\wd0-\wd2
\hskip\dimexpr\wd2-\wd0 \relax
}
\[
\leftfrac 1 {q_1} +
{\leftfrac 1 {q_2} +
{\leftfrac 1 {q_3} + 1}
} .
\]

I have placed a dot in the example to show you the horizontal width is the total width of all fractions. Note that the \strut
is essential to get the proper vertical spacing around the ones.
Now as a final step, add the diagonal dots and the lower-right fraction. We have to measure the latter first; then we can use the fact that our new \leftfrac
moves the last skip out of its fourth argument:
\[ \frac {n_0}{n_1} = q_1 +
\leftfrac 1 {q_2} +
{\leftfrac 1 {q_3} +
{\leftfrac 1 {q_4} +
{ % lower the ddots a bit
\setbox0=\hbox{$\displaystyle\ddots$}
\lower5pt\box0
% measure the lower-right fraction
\setbox0=\hbox{$\displaystyle
{} + \leftfrac 1 {q_{k-1}} + {\frac {\strut1}{q_k}}$}
\lower7pt\copy0
% give two skips for \leftfrac to shift
\hskip-\wd0
\hskip+\wd0
}
}
}
\]
This gives you your equation in the form you requested:

\phantom
and\mathrlap
.