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, MSGID_RANDY 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: skamn@my-deja.com Subject: Re: Prime number program? Date: 1999/12/06 Message-ID: <82f9mf$i8t$1@nnrp1.deja.com>#1/1 X-Deja-AN: 556934751 References: <82bk0d$55b$1@saturn.bton.ac.uk> X-Http-Proxy: 1.1 x21.deja.com:80 (Squid/1.1.22) for client 137.45.108.97 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Mon Dec 06 02:17:10 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT) Date: 1999-12-06T00:00:00+00:00 List-Id: In article <82bk0d$55b$1@saturn.bton.ac.uk>, "Oly" wrote: > Please help! > > 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 frustring hours trying to solve the problem. > > Please help! > > (o_fox@hotmail.com); > > Here is a simple procedure in C that returns if a number is prime. I had a similar Ada program but I can't find it. Hope this helps. /* return if a number is prime or not */ int IsPrime( int y) { int rema; int counter = 0; int n; for (n =1; n <= y; n++) { rema = y%n; if (rema == 0) counter = counter + 1; } if (counter <= 2) return 0; else return 1; Sent via Deja.com http://www.deja.com/ Before you buy.