标签:
/// <summary>
/// 用bool运算判断是否是素数;
/// </summary>
/// <param name="a">输入的数值</param>
/// <returns>返回的bool值</returns>
public bool sushu(int a)
{
int count = 0;
for (int i = 1; i <= a; i++)
{
if (a % i == 0)
{
count++;
}
}
bool b = true;
if (count > 2)
{
b = false;
}
return b;
}
static void Main(string[] args)
{
Console.WriteLine("请输入数字:");
int a = int.Parse(Console.ReadLine());
bool b =new Program().sushu(a);
Console.WriteLine(b);
Console.ReadLine();
标签:
原文地址:http://www.cnblogs.com/wswbk/p/4578625.html