prime.c 294 B

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