static void Main(string[] args) { int numberToFindPrimeFactors = ReadNumberToFindPrimeFactors(); List <int> primeFactors = PrimeFactors.Generate(numberToFindPrimeFactors); PrintPrimeFactors(numberToFindPrimeFactors, primeFactors); Console.ReadKey(); }
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))); }
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(); }
public void Test_1() { Assert.Equal(new int[0], PrimeFactors.For(1)); }
public void Test_93819012551() { Assert.Equal(new[] { 11, 9539, 894119 }, PrimeFactors.For(93819012551)); }
public void Test_901255() { Assert.Equal(new[] { 5, 17, 23, 461 }, PrimeFactors.For(901255)); }
public void Test_625() { Assert.Equal(new[] { 5, 5, 5, 5 }, PrimeFactors.For(625)); }
public void Test_27() { Assert.Equal(new[] { 3, 3, 3 }, PrimeFactors.For(27)); }
public void Test_9() { Assert.Equal(new[] { 3, 3 }, PrimeFactors.For(9)); }
public void Test_8() { Assert.Equal(new[] { 2, 2, 2 }, PrimeFactors.For(8)); }
public void Test_6() { Assert.Equal(new[] { 2, 3 }, PrimeFactors.For(6)); }
public void Test_3() { Assert.Equal(new[] { 3 }, PrimeFactors.For(3)); }
public void Test_2() { Assert.Equal(new[] { 2 }, PrimeFactors.For(2)); }