Re: [rant][benchmark] Sieve of Eratosthenes

new topic     » goto parent     » topic index » view thread      » older message » newer message
ChrisB said...

How on earth does this calculate primes?

b_lst (the "sieve") is initially an array of 20,000 "true".
For every [prime] number it marks all multiples of that number (prime*2 by prime) as false.
Any b_lst[i] still true by the time we get to it means that i must be prime, since by then we've processed every number smaller that it.
Invented by some ancient Greek bloke a very very long time ago.

Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu