Submitted:
09 April 2026
Posted:
09 April 2026
You are already at the latest version
Abstract
Keywords:
1. Introduction
2. Decimal–Hexadecimal Encoding
Examples
3. Database Structure
4. Core Algorithms in Python
4.1. Construction of the Database


4.2. Direct Primality Query

4.3. Recovery of the Prime-Counting Function


5. The Ternary Constraint and Compressed Encoding
5.1. The Structural Theorem
- 1.
- If , then and , so .
- 2.
- If , no candidate is divisible by 3 (beyond the value 3 itself, which is handled in the base set).
- 3.
- If , then and , so .
- : and .
- : , , , ; none zero.
- : and .
5.2. Partition of the Nibble Alphabet
| Class | Forced zero bits | Effective alphabet |
| (size 4) | ||
| none | (size 16) | |
| (size 4) |
5.3. Shannon Entropy Reduction
| Class | H (bits) | Alphabet size |
| 1.8174 | 4 | |
| 3.6352 | 16 | |
| 1.8198 | 4 | |
| Weighted mean | 2.4241 | — |
5.4. Compressed Encoding Scheme
- : a 2-bit index into .
- : the original 4-bit nibble (or a Huffman code for further gain).
- : a 2-bit index into .


6. Experimental Validation
6.1. Verification of the Ternary Constraint
| Nibble | Violation | |||
| 0 | 4535 | 1914 | 4485 | 0 |
| 1 | 0 | 1036 | 2266 | 0 |
| 2 | 2235 | 1023 | 0 | 0 |
| 3 | 0 | 511 | 0 | 0 |
| 4 | 0 | 1061 | 2255 | 0 |
| 5 | 0 | 472 | 994 | 0 |
| 6 | 0 | 522 | 0 | 0 |
| 7 | 0 | 213 | 0 | 0 |
| 8 | 2214 | 1029 | 0 | 0 |
| 9 | 0 | 502 | 0 | 0 |
| A | 1016 | 506 | 0 | 0 |
| B | 0 | 218 | 0 | 0 |
| C | 0 | 513 | 0 | 0 |
| D | 0 | 206 | 0 | 0 |
| E | 0 | 205 | 0 | 0 |
| F | 0 | 69 | 0 | 0 |
6.2. Size Comparison
| Method | Size (bytes) | bits/decade |
| Explicit prime list (32-bit) | 95,148 | — |
| Full bitmap on | 37,500 | — |
| Odd-only bitmap | 18,750 | — |
| Caraccioli original | 15,000 | 4.000 |
| Caraccioli + ternary (fixed 2/4/2 bits) | 9,544 | 2.667 |
| Caraccioli + ternary (Shannon limit) | 9,090 | 2.424 |
7. Comparison with Traditional Representations
- over the Caraccioli original (fixed scheme).
- to improvement approaching the Shannon limit with Huffman coding on the class.
- over an odd-only bitmap.
8. Discussion
9. Conclusions
- a provable lossless compression of (fixed scheme) to (Shannon limit) over the original encoding,
- encode and decode complexity,
- a combinatorial explanation for the dominant period-3 autocorrelation peak observed in the nibble sequence,
- the observation that is the unique prime inducing this exact periodic structure, by virtue of .
References
- Hardy, G. H.; Wright, E. M. An Introduction to the Theory of Numbers, 6th ed.; Oxford University Press, 2008. [Google Scholar]
- Crandall, R.; Pomerance, C. Prime Numbers: A Computational Perspective, 2nd ed.; Springer, 2005. [Google Scholar]
- Knuth, D. E. The Art of Computer Programming. In Seminumerical Algorithms, 3rd ed.; Addison-Wesley, 1997; Vol. 2. [Google Scholar]
- Cover, T. M.; Thomas, J. A. Elements of Information Theory, 2nd ed.; Wiley, 2006. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).