From: skamn@my-deja.com
Subject: Re: Prime number program?
Date: 1999/12/06
Date: 1999-12-06T00:00:00+00:00 [thread overview]
Message-ID: <82f9mf$i8t$1@nnrp1.deja.com> (raw)
In-Reply-To: 82bk0d$55b$1@saturn.bton.ac.uk
In article <82bk0d$55b$1@saturn.bton.ac.uk>,
"Oly" <o.fox@bton.ac.uk> 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.
next prev parent reply other threads:[~1999-12-06 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-12-04 0:00 Prime number program? Oly
1999-12-04 0:00 ` Robert L. Klungle
1999-12-04 0:00 ` E. Robert Tisdale
1999-12-04 0:00 ` Larry Kilgallen
1999-12-06 0:00 ` skamn [this message]
1999-12-13 0:00 ` Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox