Continued fraction convergents
Continued fraction convergents
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
Given a positive real number, if we truncate its continued fraction representation at a certain depth, we obtain a rational approximation to the real number. The sequence of successively better such approximations is its convergent sequence.
Problem:
- Given a positive rational number , specified by two positive integers , output its entire sequence of convergents.
- Given a quadratic real number , specified by three positive integers , where is not a perfect square, output the first convergents when given a positive number .