/* sieve2.c -- scaled down sieve with MAXPRIME_2 instead of 8091 */
/* Eratosthenes Sieve prime number calculation */

#define MAXITER 1
#define MAXPRIME_2 9

       char    flags[MAXPRIME_2];

main ()
{
       register int i,k;
       int      prime,count,iter;

       for (iter = 1;iter<=MAXITER;iter++) {
            count = 0;
            for(i = 0; i<MAXPRIME_2; i++)
                flags[i] = 1;
            for(i = 0; i<MAXPRIME_2; i++) {
                  if(flags[i]) {
                             prime = i + i + 3;
                             k = i + prime;
                             while (k < MAXPRIME_2) {
                                   flags[k] = 0;
                                   k+ = prime;
                             }
                             printf("\n%d",prime);
                             count++;
                   }
            }
        }
        printf("\n%d primes\n",count);
}


