/// <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));
        }
Exemplo n.º 3
0
 public void Test17()
 {
     Assert.AreEqual(3, GcdMethods.GcdBinary(462, 1071, 3, 3, 3, -3, 3, 3, 3, -3, 21));
 }
Exemplo n.º 4
0
 public void Test16()
 {
     Assert.AreEqual(21, GcdMethods.GcdBinary(462, -1071, 0));
 }
Exemplo n.º 5
0
 public void Test7()
 {
     Assert.AreEqual(1, GcdMethods.EuclidsGcd(out time, 462, 1071, 467, 0, 0));
     Console.WriteLine(time.ToString());
 }
Exemplo n.º 6
0
 public void Test15()
 {
     Assert.AreEqual(1, GcdMethods.BinaryGcd(-462, 1071, 467, 0, 0, 0, 0, 0, 0, 5));
 }
Exemplo n.º 7
0
 public void Test14()
 {
     Assert.AreEqual(3, GcdMethods.BinaryGcd(462, 1071, 3, 3, 3, 3, 3, 3, 3, 3, 21));
 }
Exemplo n.º 8
0
 public void Test13()
 {
     Assert.AreEqual(21, GcdMethods.BinaryGcd(462, 1071, 0));
 }