home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / alt / hackers / 1335 < prev    next >
Encoding:
Text File  |  1992-08-30  |  1.6 KB  |  36 lines

  1. Newsgroups: alt.hackers
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!cleggp
  3. From: cleggp@aix.rpi.edu (Paul Jason Clegg)
  4. Subject: Prime Number Generator
  5. Message-ID: <grtyj5-@rpi.edu>
  6. Nntp-Posting-Host: aix.rpi.edu
  7. Organization: Rensselaer Polytechnic Institute, Troy, NY
  8. Date: Mon, 31 Aug 1992 01:43:58 GMT
  9. Approved:  Somewhat@somewhere.edu
  10. Lines: 24
  11.  
  12. I'm interested in generating large prime numbers for use in some public key
  13. code encryption schemes, and I'm looking for the fastest way to generate all
  14. the primes from 2 up to as high as I can go on my 386/25 (Using BC++ 3.1, I
  15. figured this is somewhere in the what, 4 billion range?)  Anyway, the first
  16. method I was using was to just try every other (ie. odd) number from 3 to the
  17. integer of the square root of the number being tested for prime-ness.  But
  18. this takes quite a while.  Then in a discrete math class I found some Greek
  19. dude's theorem about just using 2, 3, 5, and 7, and if the number isn't
  20. divisible by any of those four numbers, it's prime.  But I got to thinking,
  21. 121 fits that description, but it's the square of 11, so something's amiss
  22. here.  My new algorithm (as soon as I get the HD space for BC++ 3.1) is
  23. going to keep a stack of prime numbers as it finds them; though it'll only
  24. use those prime numbers up until it maxes out their usefullness (ie. reaches
  25. the square of the highest prime number being used) at which point it will 
  26. extend the list to the next prime number.  I figure this should be a pretty
  27. good algorithm.
  28.  
  29. But.  Does anyone know of even more efficient algorithm for determining the
  30. primeness of numbers?  Has anyone ever come up with a O(n) algorithm for it?
  31.  
  32. ...Paul
  33.  
  34.  
  35.  
  36.