Exemplo n.º 1
0
 static void checkDuration(PrimaryNumberChecker checker, Stopwatch watch, string strategy, int start, int finish)
 {
     watch.Restart(); watch.Start();
     checker.getPrimaryNumbers(start, finish);
     watch.Stop();
     Console.WriteLine($"Finding all primes within [{start}, {finish}] using {strategy} took {watch.Elapsed.ToString()}");
 }
Exemplo n.º 2
0
        static void printPrimesInRange(int start, int finish)
        {
            PrimaryNumberChecker checker = new PrimaryNumberChecker(new EratosthenesSieveStrategy(finish));

            Console.WriteLine($"Primary numbers in the range: [{start}, {finish}]");
            IList <int> primaryNumbers = checker.getPrimaryNumbers(start, finish);

            foreach (int number in primaryNumbers)
            {
                Console.WriteLine(number);
            }
        }