单个循环 分解质因数

static void Main(string[] args)
        {
            Console.WriteLine("请输入一个数:");
            int num = int.Parse(Console.ReadLine());
            int i = 2;

            Console.Write(num + "=");
            do
            {

                if (num % i == 0)
                {
                    Console.Write(i + "*");
                    num = num / i;
                    i = 1;
                }
                i++;
               
            } while (num != 1 && i < num);
            Console.Write(num);
        }

你可能感兴趣的:(String)