Esempio n. 1
0
        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));
        }