static void Main()
{
int n;
int sum=0;
Console.Write("请输入一个数:");
n= int.Parse(Console.ReadLine());
for (int i=1;i<=n;i++)
{
if(n%i==0 )
{
sum+=1;
}
}
if (sum==2)
{
Console.WriteLine("结果不是质数");
}
else
{
Console.WriteLine("结果是质数");
}
转载于:https://www.cnblogs.com/zxl934734463/p/10966613.html