Prime Numbers from Quest Consultants Inc.


Quest Logo

Go to Quest Consultant's Home Page


This looks up an integer in a file and tells you whether it is prime or composite. The integer must be less than 419430400. The largest prime in the file is 419430343. The information of "prime" or "composite" is stored using one byte for each 20 integers. There is no need to store information about even numbers or numbers ending in 5. That leaves at most, numbers ending in 1, 3, 7, 9 for each ten integers ( except the first ten where 5 and 2 are prime ). By using one bit to store "prime" or "composite" for the numbers ending in 1,3,7,9 information about twenty integers is stored in 8 bits ( 1 byte ). A 20 megabyte file holds "prime" or "composite" for 20*1024*1024*20 integers. Lookup is fast since the offset into the file is the number divided by 20.


The integer


Last modified Dec 5, 1996 by John Moyer.
John Moyer's home page

Copyright © 1996, John Moyer, All rights reserved. Trademark