Algorithm for regular continued fraction of a square root

548 Views Asked by At

Say I have a number $n$, and want to find the expression of $\sqrt{n}$ as a regular continued fraction. How would I do such a thing systematically?
A naive computer algorithm wouldn't work, due to floating point errors.