nearest integer continued fraction expansion algorithm