I figured out what to do when k is even. I knew it involved doubling the period or something similar, but it wasn't working out. Sorry for the confusion.
Anyhoo, ionce you get to [tex]\sqrt{D}=[a_{0}, a_{1}, \ldots, a_{k}, a_{0}+\sqrt{D}][/tex] and k is even, you need to find x, y with [tex]x/y=[a_{0}, a_{1}, \ldots, a_{k}, 2a_{0}, a_{1}, \ldots, a_{k}][/tex], then x, y are your minimal solutions.
The [tex]2a_{0}[/tex] term shouldn't be suprising. If you were at [tex]\sqrt{D}=[a_{0}, a_{1}, \ldots, a_{k}, a_{0}+\sqrt{D}][/tex], and you wanted to find more terms, you'd see [tex]a_{k+1}=2a_{0}[/tex]. Muck about with a few examples and you'll see why this is so.
