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;
51 /* Execute the sieve */
53 while (I < SQRT_COUNT) {
55 /* Prime number - mark multiples */
66 /* Calculate the time used */
67 Ticks = clock() - Ticks;
69 /* Print the time used */
70 printf ("Time used: %lu ticks\n", Ticks);
71 printf ("Press Q to quit, any other key for list\n");
73 /* Wait for a key and print the list if not 'Q' */
74 if (toupper (cgetc()) != 'Q') {
75 /* Print the result */
76 for (I = 2; I < COUNT; ++I) {
80 if (kbhit() && toupper (cgetc()) == 'Q') {