找出100之内的所有的质数
只能被1和自身整除的数称为质数
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DmeThree
{
class Program
{
static void Main(string[] args)
{
for (int i = 2; i <=100; i++)
{
bool b = true;
for (int j = 2; j < i; j++) //判断当前判断的数字是不是质数
{
if (i % j == 0) //说明不是质数
{
b = false;
break;
}
}
if (b==true)
{
Console.WriteLine(i);
}
}
Console.ReadKey();
}
}
}
欢迎评论区进行讨论。
1万+

被折叠的 条评论
为什么被折叠?



