public void VerifiesDistinctPrimeFactorsAgainstKnownOutput() { var sieveFactorizer = new SieveOfEratosthenesFactorizer(1000); var trialDivisionFactorizer = new TrialDivisionFactorizer(1000); foreach (var numberPrimeFactorsPair in numberPrimeFactorsPairs) { int number = numberPrimeFactorsPair.Item1; int[] distinctPrimeFactors = numberPrimeFactorsPair.Item2.Distinct().ToArray(); CollectionAssert.AreEquivalent(distinctPrimeFactors, sieveFactorizer.GetDistinctPrimeFactors(number).ToArray()); CollectionAssert.AreEquivalent(distinctPrimeFactors, trialDivisionFactorizer.GetDistinctPrimeFactors(number).ToArray()); CollectionAssert.AreEquivalent(distinctPrimeFactors, NaivePrimeDeciderProviderFactorizer.GetDistinctPrimeFactors(number).ToArray()); } }
public void VerifiesDistinctPrimeFactorsAgainstNaiveFactorizer() { var sieveFactorizer = new SieveOfEratosthenesFactorizer(3481); var trialDivisionFactorizer = new TrialDivisionFactorizer(3481); for (int n = 0; n <= 3481; ++n) { CollectionAssert.AreEquivalent( NaivePrimeDeciderProviderFactorizer.GetDistinctPrimeFactors(n).ToArray(), sieveFactorizer.GetDistinctPrimeFactors(n).ToArray()); CollectionAssert.AreEquivalent( NaivePrimeDeciderProviderFactorizer.GetDistinctPrimeFactors(n).ToArray(), trialDivisionFactorizer.GetDistinctPrimeFactors(n).ToArray()); } }