public void ShouldReturnAllPrimesUpToZero() { var soe = new SieveOfEratosthenes(0); var expected = new List<long> { }; Assert.AreEqual(expected, soe.Primes); }
public Performance GetPerformance(TestConstraints testConstraints) { Stopwatch sw = new Stopwatch(); var trialDivison = new SieveOfEratosthenes(testConstraints.Limit); sw.Start(); long prime = trialDivison.Primes.ToList().Last(); return new Performance { RangeLimit = testConstraints.Limit, TimeTaken = sw.ElapsedMilliseconds }; }
List<Performance> GetSieveOfErathosthenesPeformanceTimes(long to, long increment) { var performanceValues = new List<Performance>(); for (long i = 1000; i <= to; i += increment) { Stopwatch sw = new Stopwatch(); var trialDivison = new SieveOfEratosthenes(i); sw.Start(); long prime = trialDivison.Primes.ToList().Last(); var per = new Performance { RangeLimit = i, TimeTaken = sw.ElapsedMilliseconds }; performanceValues.Add(per); } return performanceValues; }
public void ShouldReturn541AsHundredthPrime() { var soe = new SieveOfEratosthenes(541); Assert.AreEqual(541, soe.Primes.Skip(99).First()); }
public long SumOfAllPrimesLessThan(long limit) { var soe = new SieveOfEratosthenes(limit-1); return soe.Primes.Sum(); }