private void Normalize()
 {
     if (this.Numerator == 0)
     {
         this.Denominator = 1;
     }
     else
     {
         var g = NormalizedRational.GCD(this.Numerator, this.Denominator);
         this.Numerator   = this.Numerator / g;
         this.Denominator = this.Denominator / g;
     }
 }
        private static int GCD(int x, int y)
        {
            // find greatest common divisor of x and y
            int ans;
            int z;

            if (x < y)
            {
                ans = NormalizedRational.GCD(y, x);
            }
            else if (x % y == 0)
            {
                ans = y;
            }
            else
            {
                z   = x % y;
                ans = NormalizedRational.GCD(y, z);
            }
            return(ans);
        }
 private void NormalizedInvariant()
 {
     Contract.Invariant(NormalizedRational.GCD(this.Numerator, this.Denominator) == 1);
 }