Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            SuperCounter superCounter = new SuperCounter();
            int          limit        = 10;

            Console.WriteLine($"Number from 0 to {limit}");
            superCounter.Calculate(limit);
            Console.WriteLine();

            limit = 6;
            Console.WriteLine($"Numbers grade two until to {limit}");
            superCounter.SetAlgo(GradeTwo);
            superCounter.Calculate(limit);
            Console.WriteLine();

            limit = 11;
            Console.WriteLine($"Prime numbers from 2 to {limit}");
            superCounter.SetAlgo(PrimeNumbers);
            superCounter.Calculate(limit);
            Console.WriteLine();

            limit = 5;
            Console.WriteLine($"Factorial to {limit}");
            superCounter.SetAlgo(Factorial);
            superCounter.Calculate(limit);
            Console.WriteLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            SuperCounter sc = new SuperCounter();

            Console.WriteLine("Default algorithm:");
            sc.Calculate(20);
            Console.WriteLine("\nPower of 2:");
            sc.SetAlo(Power2);
            sc.Calculate(1024);
            Console.WriteLine("\nFibonacci:");
            sc.SetAlo(Fib);
            sc.Calculate(200);
            Console.WriteLine("\nFactorial:");
            sc.SetAlo(Factorial);
            sc.Calculate(720);
            Console.WriteLine("\nPrimе numbers:");
            sc.SetAlo(PrimeNumbers);
            sc.Calculate(100);
        }