private static T GreatestCommonDivisor <T>(T one, T two, IArithmetic <T> arithmetic) { T big = arithmetic.Max(arithmetic.Abs(one), arithmetic.Abs(two)); T small = arithmetic.Min(arithmetic.Abs(one), arithmetic.Abs(two)); T remainder = arithmetic.Modulo(big, small); return(arithmetic.Equals(remainder, arithmetic.Zero) ? small : AdvancedMath.GreatestCommonDivisor(small, remainder, arithmetic)); }
private static T LeastCommonMultiple <T>(T one, T two, IArithmetic <T> arithmetic) { return(arithmetic.Divide(arithmetic.Abs(arithmetic.Multiply(one, two)), AdvancedMath.GreatestCommonDivisor(one, two, arithmetic))); }