using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//找出100以內的所有孿生質數的代碼
namespace luanshengzhishu
{
class Program
{
static void Main(string[] args)
{
for(int i=2;i<97;i++)
{
if (panduan(i) == true && panduan(i + 2) == true)
{
Console.WriteLine("找到一對孿生質數,是{0},{1}",i,i+2);
}
}
}
static bool panduan(int x)//該函數用來判斷一個數字是否質數
{ bool yesorno;
int i;
for (i = 2; i < x; i++)
{
if (x % i == 0)
{
break;
}
}
if (i == x)
{
yesorno=true;
}
else
{
yesorno=false;
}
return yesorno;
}
}
}