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