Skip to content

@jkrempus /oddSieve.d
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
prime sieve on odd numbers
void oddSieve(bool[] isPrime) // index i of isPrime corresponds to 2 * i + 1
{
isPrime[] = true;
isPrime[0] = false;
auto n = isPrime.length * 2 + 1;
for(int i = 3; i * i <= n; i += 2)
if(isPrime[i/2])
for(int j = (i + i + i) / 2; j < n/2; j += i)
isPrime[j] = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.