Skip to content
StackDecode
Bit manipulationExplained

Bitwise Sieve

Sieve of Eratosthenes storing one bit per number.

Time

O(n log log n)

Extra space

O(n / 8)

Use it for

Memory-efficient prime sieve.

An animated walkthrough for this algorithm isn’t built yet. The summary above explains the idea; see the related animated algorithms below to practise the same technique.