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 /*****************************************************************************/
39 /* This is an example where register variables make sense */
40 register unsigned char* S;
47 /* Execute the sieve */
49 while (I < SQRT_COUNT) {
51 /* Prime number - mark multiples */
62 /* Calculate the time used */
63 Ticks = clock() - Ticks;
65 /* Print the time used */
66 printf ("Time used: %lu ticks\n", Ticks);
67 printf ("Press Q to quit, any other key for list\n");
69 /* Wait for a key and print the list if not 'Q' */
70 if (toupper (cgetc()) != 'Q') {
71 /* Print the result */
72 for (I = 2; I < COUNT; ++I) {
76 if (kbhit() && toupper (cgetc()) == 'Q') {