将100~200之间的素数输出!
素数是指一个大于1的正整数,除了1和它本身以外,不能被其他正整数整除。
1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int i,j; 6 for(i=101;i<=199;i++) 7 { 8 for(j=2;j<=sqrt(i);j++) 9 if(i%j==0) 10 break; 11 if(sqrt(i)<j) 12 printf("%d\n",i); 13 } 14 return 0; 15 }
原文:https://www.cnblogs.com/wsl8848/p/14533539.html