Пример #1
0
        public void Start()
        {
            FactorFinder ff  = new FactorFinder();
            int          num = InputClass.GetIntFromUser("Enter number to process");

            int[] factors = ff.GetFactors(num);
            OutputClass.SentToConsole($"\nThe factors of {num} are as follows:\n");
            for (int i = 0; i < factors.Length; i++)
            {
                OutputClass.SentToConsole($"{factors[i]}");
            }

            if (PerfectChecker.IsItPerfect(factors))
            {
                OutputClass.SentToConsole($"\n{num} is a perfect number!");
            }
            else
            {
                OutputClass.SentToConsole($"\n{num} is NOT a perfect number!");
            }


            if (PrimeChecker.IsItPrime(factors))
            {
                OutputClass.SentToConsole($"\n{num} is a prime number!");
            }
            else
            {
                OutputClass.SentToConsole($"\n{num} is NOT a prime number!");
            }

            OutputClass.SentToConsole("\nPress any key to end.");
            Console.ReadKey();
        }
        public void PrimeCheckerTest(int[] x, bool expected)
        {
            bool actual = PrimeChecker.IsItPrime(x);

            Assert.AreEqual(expected, actual);
        }