判断m是否素数
#includemain()
{
int m,i,k;
scanf(“%d”,&m);
k=sqrt(m);
for(i=2;i<=k;i++)
if(m%i==0)break;
if(i>=k+1)
printf(“%d is a prime number\n”,m);
else
printf(“%d is not a prime number\n”,m);
}
编辑澳门娱乐城:http://www.
#include <stdio.h> #include <math.h> int main(void) { int i, m; scanf("%d",&m); for(i=2;i<=sqrt(m);i++) if(m%i==0) break; m%i==0? printf("%d is a prime number!\n",m):printf("%d is not a prime number!\n",m); }