static void TestGCD(Integer expected, Integer a, Integer b) { Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(a, b)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(b, a)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(-a, b)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(-b, a)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(a, -b)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(b, -a)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(-a, -b)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(-b, -a)); }
static void TestGCD(long expected, long a, long b) { Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(a, b)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(b, a)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(-a, b)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(-b, a)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(a, -b)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(b, -a)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(-a, -b)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(-b, -a)); TestGCD(expected, (Integer)a, (Integer)b); }
static void TestGCD(int expected, int a, int b) { Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(a, b)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(b, a)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(-a, b)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(-b, a)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(a, -b)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(b, -a)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(-a, -b)); Assert.AreEqual(expected, NumberTheory.GreatestCommonFactor(-b, -a)); TestGCD(expected, (long)a, (long)b); }