From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2a687662f09731bb X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Newsgroups: comp.lang.ada Subject: Re: Request for comments on simple Ada program References: <87psp1lsc4.fsf@willow.rfc1149.net> From: Brian May Date: Wed, 16 Nov 2005 18:11:45 +1100 Message-ID: User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:0T37Nirr0YLRyOdITUmo+Y2noTw= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: snoopy.microcomaustralia.com.au X-Trace: news.melbourne.pipenetworks.com 1132125105 202.173.153.89 (16 Nov 2005 17:11:45 +1000) X-Complaints-To: abuse@pipenetworks.com X-Abuse-Info: Please forward all headers to enable your complaint to be properly processed. Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nntp.waia.asn.au!130.95.128.9.MISMATCH!news.uwa.edu.au!news1.optus.net.au!optus!snewsf0.syd.ops.aspac.uu.net!news.netspace.net.au!news.melbourne.pipenetworks.com!not-for-mail Xref: g2news1.google.com comp.lang.ada:6420 Date: 2005-11-16T18:11:45+11:00 List-Id: >>>>> "Samuel" == Samuel Tardieu writes: Samuel> procedure Print_Primes_Up_To (Upper_Bound : Potential_Prime) is Samuel> Primes : Candidates_Array (2 .. Upper_Bound) := (others => True); Samuel> begin Samuel> Check_Primes (Primes); Samuel> Print_Primes (Primes); Samuel> end Print_Primes_Up_To; The disadvantage with this approach is if you want to generate a large number of primes, the code: a) needs to generate all primes before starting to display any. b) needs additional memory to buffer all this primes first. This might be significant in some applications - e.g. if output is to go to web browser. I would suggest an approach (if feasible) involving a function "n := get_next_prime(n);" that calculates the next prime past n. Of course, it depends on the requirements of the application using this function if this is a problem or not. It might even be an advantage in some cases. -- Brian May