Esempio n. 1
0
        static void Main(string[] args)
        {
            int numberToFindPrimeFactors = ReadNumberToFindPrimeFactors();

            List <int> primeFactors = PrimeFactors.Generate(numberToFindPrimeFactors);

            PrintPrimeFactors(numberToFindPrimeFactors, primeFactors);

            Console.ReadKey();
        }
Esempio n. 2
0
 static void Main()
 {
     //Return list of Prime Factors
     //Examples: 1 = 1, 2 = 2, 3 = 3, 4 = 2 * 2, 5 = 5, 6 = 2 * 3, 7 = 7, 8 = 2 * 2 * 2, 9 = 3 * 3, 10 = 2 * 5, 11 = 11
     Console.WriteLine("2=" +
                       string.Join("*", PrimeFactors.Generate(2)));
     Console.WriteLine("4=" +
                       string.Join("*", PrimeFactors.Generate(4)));
     Console.WriteLine("5=" +
                       string.Join("*", PrimeFactors.Generate(5)));
     Console.WriteLine("6=" +
                       string.Join("*", PrimeFactors.Generate(6)));
     Console.WriteLine("8=" +
                       string.Join("*", PrimeFactors.Generate(8)));
     Console.WriteLine("9=" +
                       string.Join("*", PrimeFactors.Generate(9)));
     Console.WriteLine("10=" +
                       string.Join("*", PrimeFactors.Generate(10)));
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            List <int> resultList;

            Console.Write("Enter a number: ");
            int n = Convert.ToInt32(Console.ReadLine());

            resultList = PrimeFactors.Generate(n);
            for (int i = 0; i < resultList.Count; i++)
            {
                if (resultList[i] == 0)
                {
                    break;
                }
                Console.Write(resultList[i]);
                if (i != resultList.Count - 1)
                {
                    Console.Write(" * ");
                }
            }
            Console.WriteLine();
            Console.ReadLine();
        }
Esempio n. 4
0
 public void Test_1()
 {
     Assert.Equal(new int[0], PrimeFactors.For(1));
 }
Esempio n. 5
0
 public void Test_93819012551()
 {
     Assert.Equal(new[] { 11, 9539, 894119 }, PrimeFactors.For(93819012551));
 }
Esempio n. 6
0
 public void Test_901255()
 {
     Assert.Equal(new[] { 5, 17, 23, 461 }, PrimeFactors.For(901255));
 }
Esempio n. 7
0
 public void Test_625()
 {
     Assert.Equal(new[] { 5, 5, 5, 5 }, PrimeFactors.For(625));
 }
Esempio n. 8
0
 public void Test_27()
 {
     Assert.Equal(new[] { 3, 3, 3 }, PrimeFactors.For(27));
 }
Esempio n. 9
0
 public void Test_9()
 {
     Assert.Equal(new[] { 3, 3 }, PrimeFactors.For(9));
 }
Esempio n. 10
0
 public void Test_8()
 {
     Assert.Equal(new[] { 2, 2, 2 }, PrimeFactors.For(8));
 }
Esempio n. 11
0
 public void Test_6()
 {
     Assert.Equal(new[] { 2, 3 }, PrimeFactors.For(6));
 }
Esempio n. 12
0
 public void Test_3()
 {
     Assert.Equal(new[] { 3 }, PrimeFactors.For(3));
 }
Esempio n. 13
0
 public void Test_2()
 {
     Assert.Equal(new[] { 2 }, PrimeFactors.For(2));
 }