home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
SIMTEL
/
HITECH-C
/
MOTOROLA.EXE
/
SIEVE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-21
|
525b
|
32 lines
#include <stdio.h>
#define TRUE 1
#define FALSE 0
#define SIZE 8190
char flags[SIZE+1];
main()
{
register int k, j, i, count, prime;
printf("100 iterations\n");
for(i = 1 ; i <= 100 ; i++) {
count = 0;
for(j = 0 ; j <= SIZE ; j++)
flags[j] = TRUE;
for(j = 0 ; j <= SIZE ; j++) {
if(flags[j]) {
prime = j + j + 3;
k = j + prime;
while(k <= SIZE) {
flags[k] = FALSE;
k += prime;
}
count = count + 1;
}
}
}
printf("\n%d primes\n", count);
}