示例#1
0
 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));
 }
示例#2
0
 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);
 }
示例#3
0
 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);
 }