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); }
public static long CalcLCM(long a, long b) { return(a / OperationsOnNumbers.CalcGCD(a, b) * b); }