Exemplo n.º 1
0
        public Fraction Subtract(Fraction other)
        {
            long newDenominator = OperationsOnNumbers.CalcGCD(this.Denominator, other.Denominator);

            newDenominator = newDenominator == 1 ? this.Denominator * other.Denominator : newDenominator;

            long newNumerator = this.Numerator * (newDenominator / this.Denominator)
                                - other.Numerator * (newDenominator / other.Denominator);

            Fraction additionResult = new Fraction(newNumerator, newDenominator);

            return(additionResult);
        }
Exemplo n.º 2
0
 public static long CalcLCM(long a, long b)
 {
     return(a / OperationsOnNumbers.CalcGCD(a, b) * b);
 }