home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
comp_lan
/
85_febr
/
benmrk.lbr
/
BENMRK.SVE
< prev
next >
Wrap
Text File
|
1988-07-25
|
768b
|
34 lines
Sieve of Eratosthenes Benchmark
C Compiler Analysis
February 1985 COMPUTER LANGUAGE
/* Eratosthenes Sieve Prime Number Program in C */
#define TRUE 1
#define FALSE 0
#define SIZE 8190
char flags[SIZE+1];
main()
{
int i, prime, k, count, iter;
printf("10 iterations.\n");
for (iter = 1; iter <= 10; 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++;
}
}
}
printf("%d %d\n", prime, count);
}