home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD2.mdf
/
c
/
compiler
/
miracl
/
sieve.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-25
|
537b
|
38 lines
#include <stdio.h>
#include <system.h>
void main();
#define ITER 250
#define SIZE 250
void main ()
{
char flags[256];
int i, k, iter, count;
printf ("%d iterations\n", ITER);
for( iter = 1; iter <= ITER; iter++ )
{
count = 0;
for( i = 0; i <= SIZE; i++)
flags[i] = 0;
for( i = 2; i <= SIZE; i++ )
if ( flags[i]==0 ) /* found a prime */
{
count++;
for ( k = i + i; k <= SIZE; k += i )
flags[k] = 1;
}
}
printf ("%d primes\n", count);
exit(0);
}