The $n^{\text{th}}$ negative continued fraction convergent $x_n$ of a positive real $x$ is computed by the nested function \begin{align} x_n = k_1 - \frac{1}{k_2 - \frac{1}{k_3 - \dots - \tfrac{1}{k_n}}}, \end{align} where $k_1, \dots, k_n$ are positive integers for all $n \in \mathbb{N}$. To compute the first $n$ negative continued fraction coefficients, namely, $\{k_1, \dots, k_n \}$, of an arbitrary irrational $x$, I use the following example Mathematica code:
x = Sqrt[2];
n = 15;
Map[#[[1, 1]] &, Rest[NestList[1/(Ceiling[#] - #) &, x, n]]].
which outputs $\{ 2, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4 \}$. However, this code is not suitable if $x$ is a rational, since the recurrence diverges when $\#$ is an integer. How might I modify the above code to allow for rational $x$ and output the finite list of coefficients of its complete negative continued fraction?