#include<math.h>
main()
{
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);
}
上面一段 for后面的循环顺序是怎么样的?
#include<stdio.h>
#include<math.h>
main()
{
int m,i,k;
scanf("%d",&m);
k=sqrt(m);
for(i=2;i<=k;i++)
if(m%i==0)break;//如果m不是素数 那么i一定小于k
if(i>=k+1)
printf("%d is a prime number\n",m);
else
printf("%d is not a prime number\n",m);
}