TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Jeff Carter <[log in to unmask]>
Reply To:
Jeff Carter <[log in to unmask]>
Sat, 18 Nov 2000 11:17:47 -0600
text/plain (19 lines)
Tom Moran wrote:
>   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.

There's also a solution that is difficult to code, except in Ada:
Numbers are passed from task to task. Each task holds a prime and passes
numbers that are not multiples of that prime. If a number gets past the
last task, a new task is created for that number. Initially there is a
single task, holding 2.

Jeff Carter
"You tiny-brained wipers of other people's bottoms!"
Monty Python & the Holy Grail