예제 #1
0
 static void TestLCM(Integer expected, Integer a, Integer b)
 {
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(a, b));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(b, a));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(-a, b));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(-b, a));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(a, -b));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(b, -a));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(-a, -b));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(-b, -a));
 }
예제 #2
0
 static void TestLCM(long expected, int a, int b)
 {
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(a, b));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(b, a));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(-a, b));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(-b, a));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(a, -b));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(b, -a));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(-a, -b));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(-b, -a));
     TestLCM(expected, (long)a, (long)b);
 }
예제 #3
0
 static void TestLCM(Integer expected, long a, long b)
 {
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(a, b));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(b, a));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(-a, b));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(-b, a));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(a, -b));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(b, -a));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(-a, -b));
     Assert.AreEqual(expected, NumberTheory.LeastCommonMultiple(-b, -a));
     TestLCM(expected, (Integer)a, (Integer)b);
 }
 public int LeastCommonMultiple_ShouldCalculate(int first, int second)
 {
     return(NumberTheory.LeastCommonMultiple(first, second));
 }