Exemplo n.º 1
0
        private static void RunSumOfMultiple()
        {
            Console.WriteLine($"{NN_ENTRY}: ");
            int entry = ConsoleIntegerEntry();

            SumOfMultiple sumOfMultiple = new SumOfMultiple();

            Console.WriteLine($"{NN_RESULT}: {sumOfMultiple.MultipleOfThreeAndFive(entry)}");
        }
Exemplo n.º 2
0
        private static void RunSumOfMultipleScenario( )
        {
            Console.Clear( );
            Console.WriteLine("Sum of multiple will find the sum of all natural numbers that are multiple of 3 or 5 below the limit provide as input");
            Console.Write("Please provide limit: ");
            string input = Console.ReadLine( );

            try
            {
                uint  limit  = uint.Parse(input);
                ulong result = SumOfMultiple.Calc(limit, 3, 5);
                Console.WriteLine(string.Format("Sequence analysis result = {0}\n", result));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + "\n");
            }
        }
Exemplo n.º 3
0
        private static ISumOfMultipleStrategy GetSumOfMultipleInstance(Bootstrap bootstrap, SumOfMultiple selectedAlgo)
        {
            var plugins = bootstrap.SumOfMultiplePlugins;

            if (selectedAlgo == SumOfMultiple.AP)
            {
                return(plugins.FirstOrDefault(x => x.GetType().Name.Equals("SumOfMultipleAlgoByAP")));
            }

            else if (selectedAlgo == SumOfMultiple.BrutForce)
            {
                return(plugins.FirstOrDefault(x => x.GetType().Name.Equals("SumOfMultipleAlgoBrutForce")));
            }
            //Default strategy
            else
            {
                return(plugins.FirstOrDefault(x => x.GetType().Name.Equals("SumOfMultipleAlgoBrutForce")));
            }
        }