LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2000, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 6 Jan 2000 17:17:54 -0800
Reply-To:   David Cassell <cassell@MERCURY.COR.EPA.GOV>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   David Cassell <cassell@MERCURY.COR.EPA.GOV>
Organization:   OAO Corp.
Subject:   Re: Testing if prime
Content-Type:   text/plain; charset=us-ascii

John Whittington wrote: > > At 00:05 07/01/00 GMT, Daniel J. Nordlund wrote: > > >The question was how to test a large set of numbers for primality(?), > >efficiently. The numbers can be as large as 9999999999 (ten digits). To > test > >if a number, N, > >is prime, you only need to see if it is evenly divisible by any prime number > >less than or equal to the SQRT(N). > > Dan, I keep seeing this assertion, but frankly don't get it. It is surely > the case that one has to test whether N is divisible by ALL NUMBERS > <=SQRT(N) - not all PRIME NUMBERS <=SQRT(N).

No, Dan's right. Think about it as a sequential effort starting with the number 2. If N is divisible by *a* number less than sqrt(N), then it must be divisible by the primes which make up that divisor, and they have to be even smaller than the number you just used as the divisor.

> For example, take 46. SQRT(46) = 6.78, so that the non-unity primes > <=SQRT(46) are 3 and 5. 46 certainly doesn't divide by either of those, > but it equally certainly is not prime!

Umm, 2. You forgot 2. 46 is 2*23.

And if you don't believe me [and who wouldnt :-] then let me recommend "Elementary Number Theory" by David Burton. It's an easy read for someone with your background.

David -- David Cassell, OAO cassell@mail.cor.epa.gov Senior Computing Specialist mathematical statistician


Back to: Top of message | Previous page | Main SAS-L page