小白成长记之PTA乙级题 1007
PTA乙级题 1007. 素数对猜想 (20)
#include<stdio.h>
#include<math.h>
int main()
{
int i,j,k,temp,n=0;
int s=2;
scanf("%d",&k);
if(k==1) return 0;
else
for(i=2;i<=k;i++)
{
temp=sqrt(i);
for(j=2;j<=temp;++j)
if(i%j==0) break;
if(j>=temp+1)
{
if((i-s)==2)
n++;
s=i;
}
}
printf("%d",n);
return 0;
}