R.Tenton wrote:
At the very bottom of http://digitalmars.com/d/2.0/overview.html
there is an example implementation of the Eratosthenes' sieve.
That code is broken! It counts 1899 prime numbers, while there are only 1028
primes in the interval [1,8191]!

Are you sure? What's the mistake in the code?

What is the outermost for loop good for?

It is a translation of the C benchmark that was common in the 1980's. The outermost loop is to make it take longer so the test can be timed better.

The original:

http://home.iae.nl/users/mhx/nsieve.c

The more common later version:

http://www.paxcompiler.com/js_sieve.htm

Reply via email to