libqbe/minic/test/prime.c

29 lines
294 B
C
Raw Normal View History

#include <stdio.h>
2015-10-12 14:32:48 -04:00
main() {
int n;
int t;
int c;
int p;
c = 0;
n = 2;
2015-10-13 13:15:12 -04:00
while (n < 5000) {
2015-10-12 14:32:48 -04:00
t = 2;
p = 1;
while (t*t <= n) {
if (n % t == 0)
p = 0;
2015-10-13 13:15:12 -04:00
t++;
2015-10-12 14:32:48 -04:00
}
if (p) {
2015-11-06 19:22:49 -05:00
if (c && c % 10 == 0)
2015-10-12 16:20:59 -04:00
printf("\n");
2015-10-12 14:32:48 -04:00
printf("%4d ", n);
c++;
}
2015-10-12 16:20:59 -04:00
n++;
2015-10-12 14:32:48 -04:00
}
printf("\n");
}