C# 输入一个整数,求质因数
List<int> results = new List<int>(); int number = Int32.Parse(Console.ReadLine()); for (int i = 2; i < number; i++) { while (number % i == 0 && i != number) { results.Add(i); number /= i;//number=number/i; } } results.Add(number); foreach (var result in results) { Console.WriteLine(result); } Console.ReadKey();