套两次循环,判断整除条件即可。
#include <stdio.h> int main(void) { int i, j, n = 1000; int count1 = 0, count2; for( i = 100; i < n; i++) { for ( j = 2; j < i; j++) { if ( i % j ==0) count1++; } } count2 = 900 - count1; printf("%d", count2); return 0; }