public void ReturnRightNumbers() { var primeCalculator = new EratosthenesSieveStrategy(); IEnumerable<int> primes = primeCalculator.FindPrimesLessThan(10).ToList(); Assert.IsTrue(primes.SequenceEqual(new[] { 2, 3, 5, 7 })); }
public void ReturnRightNumbersForABiggerHighLimit() { var primeCalculator = new EratosthenesSieveStrategy(); IEnumerable<int> primes = primeCalculator.FindPrimesLessThan(100).ToList(); Assert.IsTrue(primes.SequenceEqual(new[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 })); }
private static int[] FindAndCacheAllPrimes(int maxValue) { // here we could as well read them from a file or some pre-calculated list var primeCalculator = new EratosthenesSieveStrategy(); return primeCalculator.FindPrimesLessThan(maxValue).ToArray(); }