The optimal continued fraction algorithm for rationals

This is Wieb Bosma's OCF (optimal continued fraction) algorithm for a rational number.
See Optimal continued fractions, Wieb Bosma, Indag. Math. 49 (1987), 353-379.

Here we choose the nearest integer t=[p/q] to be z+1, if p/q=z+1/2.
e=1 prints the bk and uk/vk.

Enter m (> 0):
Enter n (> 0):
Enter e (e=0 or 1):
Last modified 4th April 2008
Return to main page