prime.c (294B)
1 #include <stdio.h> 2 3 main() { 4 int n; 5 int t; 6 int c; 7 int p; 8 9 c = 0; 10 n = 2; 11 while (n < 5000) { 12 t = 2; 13 p = 1; 14 while (t*t <= n) { 15 if (n % t == 0) 16 p = 0; 17 t++; 18 } 19 if (p) { 20 if (c && c % 10 == 0) 21 printf("\n"); 22 printf("%4d ", n); 23 c++; 24 } 25 n++; 26 } 27 printf("\n"); 28 }