Exemplo n.º 1
0
        static void Problem5(ProblemArguments arguments)
        {
            long maximum = arguments.Number;

            int[] multiples = new int[maximum];
            bool  found     = false;
            long  number    = 0;

            for (int i = 1; i <= maximum; i++)
            {
                multiples[i - 1] = i;
            }


            while (!found && number < long.MaxValue)
            {
                if (!found)
                {
                    number += maximum;
                }
                found = UtilityMath.IsMultiple(multiples, number);
            }

            if (found)
            {
                Console.WriteLine("{0} is the smallest positive number that is evenly divisible by {1}", number, string.Join(",", multiples));
            }
            else
            {
                Console.WriteLine("No evenly positive multiple number found.");
            }
        }
Exemplo n.º 2
0
        public static Result SmallestMultiple(Problem arguments)
        {
            string m;
            long   maximum = arguments.LongNumber;

            int[] multiples = new int[maximum];
            bool  found     = false;
            long  number    = 0;

            for (int i = 1; i <= maximum; i++)
            {
                multiples[i - 1] = i;
            }


            while (!found && number < long.MaxValue)
            {
                if (!found)
                {
                    number += maximum;
                }
                found = UtilityMath.IsMultiple(multiples, number);
            }

            if (found)
            {
                m = string.Format("{0} is the smallest positive number that is evenly divisible by {1}", number, string.Join(",", multiples));
            }
            else
            {
                m = string.Format("No evenly positive multiple number found.");
            }
            var r = new Result(arguments.Id, m);

            return(r);
        }