I would like to reach 2 bits per number. This seems crazy, but there are lots of identical values, lots of small curves, and lots of periodic patterns. This example runs to 10000 numbers, but the compression algo has to go to 400000000, that allows us to get a 100 megabytes sized binary file containing all the 32 bits sized prime numbers.
(each number gives a gap between two consecutives prime numbers, so each number gives indirectly - and very quickly - a prime number greater or equal to 5)
Code: Select all
n = 5
ff = 1
For i = 1 To 10000
n0 = n
Repeat
n + 1
sqn = Sqr(n)
isp = 1
For j = 2 To sqn
If n % j = 0
isp = 0
Break
EndIf
Next
Until isp
gap = n
gap - n0
gap / 2
tmp = gap
g2 = 0
While tmp
tmp - ff
g2 + 1
ff ! %11
Wend
Debug Space(g2) + Str(g2)
Next