Next Continued Fraction Arithmetic 26

Continued fraction objects

        struct st_cf_rat {
          int n, d;
        };
        int next_term_from_rat(struct st_cf_rat *cf) 
        {
          int n = cf->n, d = cf->d;
          int p = n / d;             /* Integer division */
          cf->n = d;
          cf->d = n - p*d;
          return p;
        }

Next   Back