summary refs log tree commit diff
path: root/minic/test/prime.c
blob: 1dd94e7bd1eb910d99f4cda744018c8e8ccff7c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>

main() {
	int n;
	int t;
	int c;
	int p;

	c = 0;
	n = 2;
	while (n < 5000) {
		t = 2;
		p = 1;
		while (t*t <= n) {
			if (n % t == 0)
				p = 0;
			t++;
		}
		if (p) {
			if (c && c % 10 == 0)
				printf("\n");
			printf("%4d ", n);
			c++;
		}
		n++;
	}
	printf("\n");
}