Exemple #1
0
        public void Execute()
        {
            //get number to factorize
            int number = ConsoleInput.GetNumberFromUser("What number would you like to factor? ", 1);

            //determine factors (static)
            int[] factors = FactorFinder.Execute(number);
            ConsoleOutput.Factors(number, factors);

            //prime it (is not static)
            PrimeChecker primeChecker = new PrimeChecker();
            bool         result       = primeChecker.IsPrimeNumber(number);

            ConsoleOutput.PrimeNumberResult(number, result);

            //perfect num
            PerfectChecker perfectChecker = new PerfectChecker();

            perfectChecker.Number = number;
            bool isPerfect = perfectChecker.IsPerfectNumber();

            ConsoleOutput.PerfectNumberResult(number, result);
        }
Exemple #2
0
 public void TestWithTestCase(int number, int[] factors)
 {
     int[] result = FactorFinder.Execute(number);
     Assert.AreEqual(factors.Length, result.Length);
 }
Exemple #3
0
 public void TestNonPrime()
 {
     int[] result = FactorFinder.Execute(42);
     //1, 2, 3, 6, 7, 14, 21, 42
     Assert.AreEqual(8, result.Length);
 }
Exemple #4
0
 public void TestSimple()
 {
     int[] result = FactorFinder.Execute(13);
     Assert.AreEqual(2, result.Length);
 }