"Generalization of simple continued fraction algorithm" - читать интересную книгу автора (Vaughan.)