summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.misc-tests/sieve.c
blob: de250e8e5a0c4633ce779c27430643b7df1ea4a6 (plain)
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
#define TRUE 1
#define FALSE 0
#define SIZE 8190

char flags[SIZE+1];

main()
{
	register int i, prime, k, count, iter;
	for (iter=1;iter<=100;iter++) 		{
		count=0;
		for (i=0;i<=SIZE;i++)
			flags[i]=TRUE;
		for (i=0;i<=SIZE;i++) {
			if (flags[i]) {
				prime=i+i+3;
				for (k=i+prime;k<=SIZE;k+=prime)
					flags[k]=FALSE;
				count++;
			}
		}
	}
	return 0;
}