This article says:
Every prime number can be expressed as
30k±1
,30k±7
,30k±11
, or30k±13
for somek
. That means we can use eight bits per thirty numbers to store all the primes; a million primes can be compressed to 33,334 bytes
"That means we can use eight bits per thirty numbers to store all the primes"
This "eight bits per thirty numbers" would be for k, correct? But each k value will not necessarily take-up just one bit. Shouldn't it be eight k values instead?
"a million primes can be compressed to 33,334 bytes"
I am not sure how this is true.
We need to indicate two things:
VALUE of k (can be arbitrarily large)
STATE from one of the eight states (-13,-11,-7,-1,1,7,11,13)
I am not following how "33,334 bytes" was arrived at, but I can say one thing: as the prime numbers become larger and larger in value, we will need more space to store the value of k.
How, then can we fix it at "33,334 bytes"?
Largest Known Primes DatabaseOur central database acts as a “Guinness book” of prime number records! This list includes the 5000 largest known primes and smaller ones of selected forms updated hourly.
Sieve of Atkin speeds up (asymptotically) the process of generating prime numbers. However, it is more complicated than the others. Comparing this running time with the previous ones shows that the sieve of Atkin is the fastest algorithm for generating prime numbers.
The article is a bit misleading: we can't store 1 million primes, but we can store all primes below 1 million.
The value of k comes from its position in the list. We only need 1 bit for each of those 8 permutations (-13,-11..,11,13)
In other words, we'll use 8 bits to store for k=0, 8 to store for k=1, 8 to store for k=2, etc. By letting these follow sequentially, we don't need to specify the value of k for each 8 bits - it's simply the value for the previous 8 bits + 1.
Since 1,000,000 / 30 = 33,333 1/3, we can store 33,334 of these 8 bit sequences to represent which values below 1 million are prime, since we cover all of the values k can have without 30k-13 exceeding the limit of 1 million.
You don't need to store each value of k. If you want to store the prime numbers below 1 million, use 33,334 bytes - the first byte corresponds to k=0, the second to k=1 etc. Then, in each byte, use 1 bit to indicate "prime" or "composite" for 30k+1, 30k+7 etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With