Stern-Brocot number system implementation