2 * Calculate all primes up to a specific number.
15 /*****************************************************************************/
17 /*****************************************************************************/
21 #define COUNT 8192 /* Up to what number? */
22 #define SQRT_COUNT 91 /* Sqrt of COUNT */
24 static unsigned char Sieve[COUNT];
28 /*****************************************************************************/
30 /*****************************************************************************/
34 #pragma staticlocals(1);
43 /* This is an example where register variables make sense */
44 register unsigned char* S;
49 printf ("Sieve benchmark - calculating primes\n");
50 printf ("between 2 and %u\n", COUNT);
51 printf ("Please wait patiently ...\n");
56 /* Execute the sieve */
58 while (I < SQRT_COUNT) {
60 /* Prime number - mark multiples */
71 /* Calculate the time used */
72 Ticks = clock() - Ticks;
74 /* Print the time used */
75 printf ("Time used: %lu ticks\n", Ticks);
76 printf ("Press Q to quit, any other key for list\n");
78 /* Wait for a key and print the list if not 'Q' */
79 if (toupper (cgetc()) != 'Q') {
80 /* Print the result */
81 for (I = 2; I < COUNT; ++I) {
85 if (kbhit() && toupper (cgetc()) == 'Q') {