Post Reply 
Fast prime finder??
08-01-2016, 09:59 PM
Post: #7
RE: Fast prime finder??
There are really no formulas for primes. The primes seem to occur at random (with a known density of ln(N)/N for the number of primes up to N). One can do clever sieving and use some pseudo-prime tests (like Fermat's) to check.

For searching (not on calculators), I've often used a storage of 30 numbers in 8 bits. Checking all numbers not divisible by 30, one get that primes have remainder of (1,7,11,13,17,18,23,29). I pack 30 numbers into one byte and set the appropriate bit if that number is prime. One can go higher with more complicated packing. This is still linear. One can do a bit better.

A more efficient packing is to store the difference between primes as primes get large. This is a bit complicated.

None of this tells whether a number is prime, but most prime checking methods work better with a bunch of stored primes.

https://en.wikipedia.org/wiki/Primality_test gives some methods.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Fast prime finder?? - Namir - 07-28-2016, 08:22 PM
RE: Fast prime finder?? - Claudio L. - 07-29-2016, 02:50 AM
RE: Fast prime finder?? - Namir - 07-29-2016, 07:27 AM
RE: Fast prime finder?? - Namir - 07-29-2016, 12:03 PM
RE: Fast prime finder?? - ttw - 08-01-2016 09:59 PM
RE: Fast prime finder?? - Namir - 08-02-2016, 12:01 AM
RE: Fast prime finder?? - ttw - 08-03-2016, 08:36 AM
RE: Fast prime finder?? - Namir - 08-03-2016, 11:07 AM
RE: Fast prime finder?? - Namir - 08-03-2016, 11:50 AM
RE: Fast prime finder?? - Namir - 08-04-2016, 11:54 PM
RE: Fast prime finder?? - Claudio L. - 08-05-2016, 12:46 AM



User(s) browsing this thread: 1 Guest(s)