예제 #1
0
        public void TestFactoization(int numberToTest, int[] primeFactors)
        {
            Factorizer factorizer = new Factorizer();

            factorizer.FindPrimeFactorsFor(numberToTest);

            List<int> result = factorizer.PrimeFactors();

            int[] primeFactorsArray = result.ToArray();

            Assert.AreEqual(primeFactors, primeFactorsArray);
        }
예제 #2
0
        public static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("Number to Factorize:");

                string number = Console.ReadLine();

                Factorizer factorizer = new Factorizer();

                factorizer.FindPrimeFactorsFor(int.Parse(number));

                List<int> primeFactors = factorizer.PrimeFactors();

                Console.WriteLine("Ordered Prime Factors:");

                foreach (int prime in primeFactors)
                {
                    Console.WriteLine("    " + prime);
                }
            }
        }