📜  c#循环示例 - C#代码示例

📅  最后修改于: 2022-03-11 14:49:06.039000             🧑  作者: Mango

代码示例1
bool isPrime = false;
int number = 2;
while (number <= 100)
{
    isPrime = true;
    for (int i = 2; i < number; ++i)
    {
        if (number % i == 0)
        {
            isPrime = false;
            break;
        }
    }
    if (isPrime)
    {
        Console.Write(number);
        Console.Write(" ");
    }
    number++;
}