View Single Post
Old 2007-07-08, 00:49   #46
Citrix
 
Citrix's Avatar
 
Jun 2003

2×787 Posts
Default

ALso when you program does
Are we missing a possible prime by doing composite_table[i] = last_composite + max_prime;
Shouldn't we look to see if last_composite is already greater than low_end_of_range or not?

Code:
for (i = save_used_in_range; i < primes_used_in_range; i++)
  {
    max_prime = prime_table[i];
    last_composite = (low_end_of_range / max_prime) * max_prime;
    composite_table[i] = last_composite + max_prime; 

    /* We only care about odd composites since the sieve range only refers
       to odd values. */
    if (!(composite_table[i] & 1))
      composite_table[i] += max_prime;
  }
Citrix is offline   Reply With Quote