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)); }
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); }
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)); }