// By the algorithm definition the number which is checked should be more than 3 public static void MillerRabinPrimalityShouldThrowEx(String testcase) { // Arrange BigInteger number = BigInteger.Parse(testcase); BigInteger rounds = 1; // Assert Assert.Throws <ArgumentException>(() => MillerRabinPrimalityChecker.IsProbablyPrimeNumber(number, rounds)); }
public static bool MillerRabinPrimalityWork(String testcase) { // Arrange BigInteger number = BigInteger.Parse(testcase); // Recommended number of checks' rounds = Log2(number) as Biginter has no Log2 function we need to convert Log10 BigInteger rounds = (BigInteger)(BigInteger.Log10(number) / BigInteger.Log10(2)); // Act var result = MillerRabinPrimalityChecker.IsProbablyPrimeNumber(number, rounds); // Assert return(result); }