#include
//让n被i除(i的值从2到n-1)
int main()
{
int n,i;
printf("please enter a integer number,n=?");
scanf("%d",&n);
for(i=2;i<=n-1;i++)
if(n%i==0) break;
if(i
",n);
else printf("%d is a prime number.
",n);
return 0;
}
*******************************************************************************************
#include
#include
//让n被i除(i的值从2到根号n)
int main()
{
int n,i,k,a=0;
printf("please enter a integer number,n=?");
scanf("%d",&n);
k=sqrt(n);
for(i=2;i<=k;i++)
if(n%i==0)break;
if(i<=k)printf("%d is not a prime number.
",n);
else printf("%d is a prime number.
",n);
return 0;
}