Fri, 17 Nov 2000 22:25:50 -0800
|
As I recall, RR's Ada compilers used to come with that as an example Ada
program. That was a long time ago, but it's conceivable it's on
www.rrsoftware.com Byte magazine used to use it as a benchmark, but
that was a really long time ago.
I just looked on BIX and found three versions from 1988, for the Mac,
the TI Color Computer, and, in Small-C, for the 8088-80386.
The idea is straightforward: Create a boolean array with True for each
potential prime from 2 .. N. Then take each known prime in turn (2 is a
known prime) and mark all its multiples as False (not prime). The ones
left True when you are done are not divisibly by any number less than
themselves (except 1 of course) so they must be primes. It's pretty
straightforward to code.
|
|
|