public void TestNonPrimalityOfExampleNumbers() { Assert.IsFalse(PrimeNumberMath.IsPrime(4), "4"); Assert.IsFalse(PrimeNumberMath.IsPrime(9), "9"); Assert.IsFalse(PrimeNumberMath.IsPrime(29209157L), "29209157L"); Assert.IsFalse(PrimeNumberMath.IsPrime(6863624473L), "6863624473L"); }
public void TestPrimalityOf1235() { Assert.IsTrue(PrimeNumberMath.IsPrime(1)); Assert.IsTrue(PrimeNumberMath.IsPrime(2)); Assert.IsTrue(PrimeNumberMath.IsPrime(3)); Assert.IsTrue(PrimeNumberMath.IsPrime(5)); Assert.IsTrue(PrimeNumberMath.IsPrime(7)); Assert.IsTrue(PrimeNumberMath.IsPrime(65537)); }
public void TestPrimeFactorization() { var rnd = new System.Random(1); for (int i = 0; i < 1000; ++i) { int number = rnd.Next(1, 0x7FFFFFF); var list = PrimeNumberMath.PrimeFactorization(number); var number2 = PrimeNumberMath.GetNumberFromPrimeFactors(list); Assert.AreEqual(number, number2); Assert.IsTrue(PrimeNumberMath.IsPrime(list[list.Count - 1].PrimeNumber)); } }