回复 楼主 zxjbc
#include <stdio.h>#include <math.h>
void main()
{
int x,i,k;
printf("please enter a integer number:");
scanf("%d",&x); /*输入一个整数*/
k=(int)sqrt(x); /*对M求平方根,再取整*/
for (i=2;i<=k;i++) /*i作为除数*/
if(x%i==0) break; /*如果m被i整除,m肯定不是素数*/
if(i>k) printf("%d is a prime number\n",m);
else printf("%d is not a prime number\n",m);
}