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