小编San*_*res的帖子

打印从 0 到 10,000 的质数

我目前正在尝试创建一个程序,该程序仅使用 for、do while 和 ifs 来打印从 0 到 10,000 的素数。我创建了这个程序,但它没有运行

static void Main(string[] args)
    { 
        for (int x = 2; x < 10000; x++)
        { 
            for (int y = 1; y < x; y++)
            { 
                if (x % y != 0)
                {
                    Console.WriteLine(x); 
                }  
            }
            Console.ReadKey();
        }
Run Code Online (Sandbox Code Playgroud)

我不知道问题出在哪里,也不知道 for inside 是否重置。

c# primes for-loop numbers do-while

2
推荐指数
1
解决办法
3万
查看次数

标签 统计

c# ×1

do-while ×1

for-loop ×1

numbers ×1

primes ×1