题解 | #KiKi求质数个数#
KiKi求质数个数
https://www.nowcoder.com/practice/d3a404ee0f8d41f98bf4707035d91086
#include <stdio.h> #include<math.h> int main() { int i = 0, j = 0, flag = 0, count = 0; for (i = 101; i < 1000; i += 2) { flag = 1; for (j = 2; j <= sqrt(i); j++) { if (i % j == 0) { flag = 0; break; } } if (1 == flag) count++; } printf("%d", count); return 0; }