4 ms·
Well, not really. It's closer to trial division, though even that doesn't go through every single multiple from 1-n. The difference is the sieve works on a lar
by hexane360 10y ago
Well, not really. It's closer to trial division, though even that doesn't go through every single multiple from 1-n.
The difference is the sieve works on a large batch of numbers, and only tests divisibility with numbers not known to be composite, and less than sqrt(n).
https://en.wikipedia.org/wiki/Trial_division https://en.wikipedia.org/wiki/Trial_division