Ejemplo n.º 1
0
        /// <summary>
        /// Program entry point.
        /// </summary>
        public static void Main(string[] args)
        {
            //// Array to analyze. More in tests.
            int[] arr = new int[] { 300181, 223744, -38, 79235168 };

            int timeByStopwatch;
            int timeByDateTime;

            // Writing results.
            Console.Write("Numbers to calculate greatest common divisor: ");
            WriteArrayToConsole(arr);
            Console.WriteLine();

            Console.Write("Euclid algorithm work result: ");
            Console.WriteLine(GCDCalculator.GCDArrayCalculator(GCDCalculator.Euclid, out timeByStopwatch, out timeByDateTime, arr));
            Console.WriteLine("Time Taken: {0}ms by Stopwatch, {1}ms by DateTime", timeByStopwatch, timeByDateTime);
            Console.WriteLine();

            Console.Write("Binary Stein algorithm work result: ");
            Console.WriteLine(GCDCalculator.GCDArrayCalculator(GCDCalculator.Stein, out timeByStopwatch, out timeByDateTime, arr));
            Console.WriteLine("Time Taken: {0}ms by Stopwatch, {1}ms by DateTime", timeByStopwatch, timeByDateTime);
            Console.WriteLine();

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Program entry point.
        /// </summary>
        public static void Main(string[] args)
        {
            //// Array to analyze. More in tests.
            int[] arr = new int[] { 300181, 223744, 38 };

            // Writing results.
            Console.Write("Numbers to calculate greatest common divisor: ");
            WriteArrayToConsole(arr);
            Console.WriteLine();

            GCDCalculator.EuclidTimeTaken(arr);
            Console.Write("Euclid algorithm work result: ");
            Console.WriteLine(GCDCalculator.Euclid(arr));
            Console.WriteLine();

            GCDCalculator.SteinTimeTaken(arr);
            Console.Write("Binary Stein algorithm work result: ");
            Console.WriteLine(GCDCalculator.Stein(arr));
            Console.WriteLine();

            Console.ReadKey();
        }