Exemplo n.º 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));
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }