home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: sci.math
- Path: sparky!uunet!secapl!Cookie!frank
- From: frank@Cookie.secapl.com (Frank Adams)
- Subject: Re: Primes
- Message-ID: <1992Aug25.224828.123034@Cookie.secapl.com>
- Date: Tue, 25 Aug 1992 22:48:28 GMT
- References: <9208171021.aa01492@Paris.ics.uci.edu> <1992Aug18.091619.10152@waikato.ac.nz> <1992Aug22.040442.17832@mailer.cc.fsu.edu>
- Organization: Security APL, Inc.
- Lines: 26
-
- In article <1992Aug22.040442.17832@mailer.cc.fsu.edu> rose@fsu1.cc.fsu.edu writes:
- >In article <1992Aug18.091619.10152@waikato.ac.nz>, bill@waikato.ac.nz writes...
- >>Does anyone know how Mathematica stores its table of primes, and how efficient
- >>it is in terms of space and access time? What's the minimum space a table
- >>of primes can be compressed into if constant access time to find the nth prime
- >>is required?
- >>
- >In general, one can use a bitmap to represent a prime number table. Some
- >compression can be obtained by representing only odd numbers, or only
- >odd numbers not divisible by 3.
- >Then the computer can count primes by using the count bits function of the
- >hardware amazingly fast. If the computer does not have a count bits
- >function, then this technique is lost.
-
- No, it isn't. Software bit-counting, using a table lookup method, is also
- very fast. You can't do it directly in most higher-level languages,
- however, without giving up a lot of the speed.
-
- However, this does not answer the original question, which required constant
- access time to find the nth prime. This can be provided by including a list
- of the (n*k)th primes for some (fairly large) k.
-
- This method, like just listing the primes, requires O(n) space to store the
- primes (with or without the auxilliary table). The difference is the
- constant. I doubt you can do better than this maintaining O(1) access time
- for the nth prime; with O(log n) time it might be possible.
-