Post Reply 
An iteration produces all the prime numbers
02-14-2021, 03:38 PM
Post: #6
RE: An iteration produces all the prime numbers
(02-14-2021 03:05 PM)ttw Wrote:  First one gets 6*K+(1,5) then 30*K+(1,7,11,13,17,19,23,29) and so forth. I like the 30*k method as I can store 30 blocks of 30 numbers in a single byte. Later, one needs fancier methods. It becomes more efficient to store the distances between primes. Then even store that distance using a Universal Code.

Storing primes using wheels is nice, but data compression ratio is still a constant

wheel(2,3), compression ratio = 1 / (1 - 1/2 - 1/3 + 1/(2*3)) = 3
wheel(2,3,5), compression ratio = 1 / (1 - 1/2 - 1/3 - 1/5 + 1/(2*3) + 1/(2*5) + 1/(3*5) - 1/(2*3*5)) = 3.75
...

Assuming we do not need random access, but simply O(1) way to get next prime (like OP formula).
Is there a way to do better ?

Does storing prime gaps give better compression ratio ?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: An iteration produces all the prime numbers - Albert Chan - 02-14-2021 03:38 PM



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