8sa1-gcc/gcc/testsuite/gcc.misc-tests/sieve.c
Jeff Law 921e5a0eb4 Initial revision
From-SVN: r14840
1997-08-19 01:34:40 -06:00

27 lines
378 B
C

#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++;
}
}
}
/* */ exit(0); /* */
}