标签:stdio.h clu pre \n prime turn isp print number
#include <stdio.h> #include <math.h> int main() { int n,i,k; int isprime=1; scanf("%d",&n); k=sqrt(n);//n的每一对因子必有一个大于根号n,一个大于根号n for(i=2;i<=k;i++) { if(n%i==0) { isprime=0; break; } } if(isprime==1) { printf("%d is a prime number\n",n); } else { printf("%d is not a prime number\n",n); } return 0; }
标签:stdio.h clu pre \n prime turn isp print number
原文地址:https://www.cnblogs.com/qfdy123/p/9986042.html