/// <summary>
        /// Computes GCD of many int numbers, one of them shouldn't be zero.
        /// </summary>
        /// <param name="gcd">Euclidean or Stein algorithm.</param>
        /// <param name="array">The array of numbers.</param>
        /// <returns>Returns GCD.</returns>
        public static int ComputeGcd(GcdMethods gcd, int[] array)
        {
            GcdArrayMethod method;

            if (gcd == GcdMethods.Stein)
            {
                method = GcdStein;
            }
            else
            {
                method = GcdEuclid;
            }

            return(method(array));
        }
        /// <summary>
        /// Computes GCD of two int numbers, one of them shouldn't be zero.
        /// </summary>
        /// <param name="gcd">Euclidean or Stein algorithm.</param>
        /// <param name="a">The first number.</param>
        /// <param name="b">The second number.</param>
        /// <returns>Returns GCD.</returns>
        public static int ComputeGcd(GcdMethods gcd, int a, int b)
        {
            GcdMethod method;

            if (gcd == GcdMethods.Stein)
            {
                method = GcdStein;
            }
            else
            {
                method = GcdEuclid;
            }

            return(method(a, b));
        }
예제 #3
0
 public void Test17()
 {
     Assert.AreEqual(3, GcdMethods.GcdBinary(462, 1071, 3, 3, 3, -3, 3, 3, 3, -3, 21));
 }
예제 #4
0
 public void Test16()
 {
     Assert.AreEqual(21, GcdMethods.GcdBinary(462, -1071, 0));
 }
예제 #5
0
 public void Test7()
 {
     Assert.AreEqual(1, GcdMethods.EuclidsGcd(out time, 462, 1071, 467, 0, 0));
     Console.WriteLine(time.ToString());
 }
예제 #6
0
 public void Test15()
 {
     Assert.AreEqual(1, GcdMethods.BinaryGcd(-462, 1071, 467, 0, 0, 0, 0, 0, 0, 5));
 }
예제 #7
0
 public void Test14()
 {
     Assert.AreEqual(3, GcdMethods.BinaryGcd(462, 1071, 3, 3, 3, 3, 3, 3, 3, 3, 21));
 }
예제 #8
0
 public void Test13()
 {
     Assert.AreEqual(21, GcdMethods.BinaryGcd(462, 1071, 0));
 }