c# while循环找质数

Console.Write("输入");
int B =int.Parse( Console.ReadLine());
int a, b;
a = 1;
while ( a < B)
{
a++;
b = 1;
while ( b <= a - 1)
{
b++;
if (a % b == 0)
break;
}
if (b == a)
{

Console.WriteLine("质数{0}", a);
}

}
Console.ReadLine();
展开阅读全文

没有更多推荐了,返回首页