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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4117034ae215d480 X-Google-Attributes: gid103376,public From: "E. Robert Tisdale" Subject: Re: Prime number program? Date: 1999/12/04 Message-ID: <38499490.1C8AEE2B@netwood.net>#1/1 X-Deja-AN: 556680025 Content-Transfer-Encoding: 7bit References: <82bk0d$55b$1@saturn.bton.ac.uk> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: newsabuse@supernews.com Organization: Posted via Supernews, http://www.supernews.com MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-12-04T00:00:00+00:00 List-Id: Oly wrote: > I have to build an Ada program which tells the user > if the number which they have entered is a prime number or not. > I am still a newbie at Ada (and crap at maths) > and have spent many wasted and frustrating hours > trying to solve the problem. I used Lycos to search for +prime +number +algorithm and I found lots of stuff including http://www.utm.edu/research/primes/ It is very hard to determine whether or not a number n is prime and that is one of the reasons why prime number figure very prominently in encryption algorithms. Suppose that the square root of n is not an integer. Then you will need to test whether n/p is an integer for every prime number p < sqrt(n) which means that you need a list of all the prime numbers p < sqrt(n). Programs which find all the prime numbers in a range of integers are called prime number sieves. The one on my computer is called "primes." $ primes 0 10 2 3 5 7 $ Hope this helps, E. Robert Tisdale