求质数(素数)C#程序

时间:2017.2.5 编辑: 叶建勇 阅读量:2939 全屏

       for (int i = 29892; i < 29894
                ; i++)
            {
                bool f = true;
                for (int j = 2; j < i; j++)
                {
                    if (i % j == 0)
                    {
                        f = false;
                    }
                }
                if (f)
                {
                    Console.WriteLine("素数:" + i);
                }
            }
            Console.ReadLine();