https://en.wikipedia.org/wiki/Prime_number_theorem#Approxima...
So with the kth prime ~= k log k, the ratio of primes is 1 / log k. Yes that drops to zero, but very slowly.
You can use the upper bound of the kth prime to build a sufficiently large sieve, which can be done O(n).
If you don't care about computation time, then why stop there?
You can encode the Mth Mersenne with the integer M.
But then I have to keep patching the code every time a new one comes out. Too hard!
Decompressing it, on the other hand, would be pretty slow however. Are primality tests O(n) or O(nlogn)? That puts decompression up to O(n^2) without a pre computed lookup table.