Preprint
Article

This version is not peer-reviewed.

A Decimal–Hexadecimal Block Encoding for Prime Storage with Modular Compression via the Ternary Constraint

Submitted:

09 April 2026

Posted:

09 April 2026

You are already at the latest version

Abstract
We describe a decimal–hexadecimal block encoding for primality over a finite stored range. Since every prime greater than 5 must lie in one of the residue classes 1, 3, 7, 9 (mod 10), each decimal block of size ten can be encoded by a 4-bit word indicating which of the candidates 10k + 1, 10k + 3, 10k + 7, and 10k + 9 are prime. This yields a nibble-based storage scheme supporting exact primality queries and exact recovery of the prime-counting function π(x) by cumulative popcount. We then establish a structural theorem arising from the congruence 10 ≡ 1 (mod 3): for k ≡ 0 (mod 3) the candidates 10k + 3 and 10k + 9 are always composite, and for k ≡ 2 (mod 3) the candidates 10k + 1 and 10k + 7 are always composite. This partitions the nibble alphabet into three classes of sizes 4, 16, and 4, reducing the Shannon entropy from 4 bits to 2.42 bits per nibble and yielding a lossless compression of 39.4% over the original encoding with O(1) decode complexity. We present data structures, Python routines, and experimental validation up to 300,000.
Keywords: 
;  ;  ;  ;  ;  ;  ;  ;  ;  ;  ;  ;  ;  ;  
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.
Prerpints.org logo

Preprints.org is a free preprint server supported by MDPI in Basel, Switzerland.

Subscribe

Disclaimer

Terms of Use

Privacy Policy

Privacy Settings

© 2026 MDPI (Basel, Switzerland) unless otherwise stated