comp.lang.ada
 help / color / mirror / Atom feed
From: "E. Robert Tisdale" <edwin@netwood.net>
Subject: Re: Prime number program?
Date: 1999/12/04
Date: 1999-12-04T00:00:00+00:00	[thread overview]
Message-ID: <38499490.1C8AEE2B@netwood.net> (raw)
In-Reply-To: 82bk0d$55b$1@saturn.bton.ac.uk

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 <edwin@netwood.net>





  parent reply	other threads:[~1999-12-04  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 ` Larry Kilgallen
1999-12-04  0:00 ` E. Robert Tisdale [this message]
1999-12-04  0:00 ` Robert L. Klungle
1999-12-06  0:00 ` skamn
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