TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Proportional Font
Show Text Part by Default
Condense Mail Headers

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

Print Reply
Content-Transfer-Encoding:
7bit
Sender:
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Subject:
From:
Jeff Carter <[log in to unmask]>
Date:
Sat, 18 Nov 2000 11:17:47 -0600
Content-Type:
text/plain; charset=us-ascii
MIME-Version:
1.0
Reply-To:
Jeff Carter <[log in to unmask]>
Parts/Attachments:
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

ATOM RSS1 RSS2