A blazing-fast Rust implementation to find and analyze productive numbers β a fascinating and rare class of integers deeply connected to prime number theory.
A number N is productive (OEIS A089395) if:
- N + 1 is prime
- For every possible digit split A|B, the product (A Γ B) + 1 is also prime
Single-digit productive numbers: {1, 2, 4, 6}
- 1: 1+1=2 β (prime), no splits
- 4: 4+1=5 β (prime), no splits
- 3: 3+1=4 β (not prime) β not productive
Multi-digit example: 2026
- 2026 + 1 = 2027 β (prime)
- Split 2|026: (2 Γ 26) + 1 = 53 β (prime)
- Split 20|26: (20 Γ 26) + 1 = 521 β (prime)
- Split 202|6: (202 Γ 6) + 1 = 1213 β (prime)
All conditions satisfied β 2026 is productive β
- Sieve of Eratosthenes: O(1) lookup for primes β€ 65,536
- Adaptive Miller-Rabin: Minimal witnesses based on input range
- 1 witness for n < 2,047
- 2 witnesses for n < 1,373,653
- Up to 12 witnesses for full u64 range
- Parallel Processing: Leverages all CPU cores with Rayon
- Smart Early Exit: Rejects odd numbers > 1 instantly (n+1 would be even)
- Crash Recovery: Resume interrupted searches automatically
- Atomic Saves: Prevents state corruption with write-then-rename
- Progress Tracking: Real-time statistics with
indicatif
- Split Analysis: Detailed CSV export of all digit splits
- Balanced Numbers: Identifies numbers where all split products have equal digit length
- Strong Primes: Finds cryptographically valuable primes where (N+1)/2 is also prime
- Visualization: Automatic graph generation with gnuplot
- Overflow-safe arithmetic with
checked_mul/checked_add - Comprehensive test suite (unit + integration + benchmarks)
- Deterministic results (no probabilistic algorithms)
| Metric | Value | Notes |
|---|---|---|
| Productive Numbers Found | 203 | 97.6% of all known (208 total up to 10ΒΉΒ³) |
| Splits Analyzed | 917 | All possible digit divisions |
| Primality Ratio | 99.89% | 916/917 splits produced primes |
| Strong Primes | 38 (18.72%) | (N+1)/2 also prime |
| Perfectly Balanced | 70 (34.48%) | All splits β same digit length |
| Density | 1 per 49 million | Extremely rare |
-
"Perfectly Balanced Numbers" β Original concept
- 70 numbers where Coefficient of Variation = 0%
- Example: 71866 (all splits produce 5-digit primes)
-
Comprehensive Statistical Framework
- Variance analysis of split product lengths
- Distribution histograms by digit count
- Correlation between number size and balance
-
First High-Performance Rust Implementation
- 3-4x faster than naive Miller-Rabin
- ~10M numbers/second on modern CPUs
- Rust 1.70+ (install here)
- Optional: gnuplot (for visualizations)
- Optional: Python 3.8+ (for analysis scripts)
# Clone repository
git clone https://github.com/santitub/productive-numbers.git
cd productive-numbers
# Build optimized binary
cargo build --release
# Run tests
cargo test
# Run benchmarks
cargo test --release -- --ignored --nocapture# Search up to 1 billion (takes ~2 minutes on 16-core CPU)
./target/release/productive-numbers --limit 1000000000
# Resume previous search
./target/release/productive-numbers --limit 10000000000
# Verbose output
./target/release/productive-numbers --limit 100000000 -vv
# Custom parameters
./target/release/productive-numbers \
--start 1000000 \
--limit 2000000 \
--chunk-size 100000 \
--output-file my_results.txt# 1. Find productive numbers
cargo run --release -- --limit 10000000000
# 2. Analyze all digit splits
python3 scripts/analyze_all_splits.py
# 3. Generate comprehensive report
bash scripts/master_analysis.sh
# 4. View results
cat analysis_results_*/SUMMARY.txtGenerates splits_analysis.csv with columns:
- NΓΊmero (N)
- SplitPos (position k)
- A, B (split parts)
- AΓB+1 (product)
- Primo? (is prime?)
- Digitos (digit count)
Produces 7 comprehensive reports:
- N+1 Verification β Confirms all N+1 are prime
- Global Statistics β Primality ratios, averages
- Digit Distribution β Histogram of product lengths
- Top Performers β Numbers with 100% prime splits
- Balance Conjecture β Variance analysis (CV%)
- Strong Primes β (N+1)/2 primality check
- CV Histogram β Distribution of balance coefficients
- Productive numbers by digit count
- Coefficient of Variation vs. number size
- Mathematical Theory β Formal definitions & proofs
- Algorithm Details β Miller-Rabin implementation
- Results Analysis β In-depth findings
| Range | Time | Speed | Notes |
|---|---|---|---|
| 0 β 10βΆ | 0.1s | 10M/s | Mostly sieve lookups |
| 0 β 10βΉ | 2 min | 8.3M/s | Mixed sieve + Miller-Rabin |
| 0 β 10ΒΉβ° | 20 min | 8.3M/s | Predominantly Miller-Rabin |
Memory Usage: ~64KB (sieve) + 10MB (overhead)
| Version | Speed | Speedup |
|---|---|---|
| Naive Miller-Rabin (12 witnesses) | 2.5M/s | 1.0x |
| + Sieve for small primes | 5.8M/s | 2.3x |
| + Adaptive witnesses | 8.3M/s | 3.3x |
| + Odd number rejection | 10M/s | 4.0x |
We welcome contributions! See CONTRIBUTING.md for guidelines.
- Extend search to 10ΒΉβ΅+ (distributed computing?)
- GPU acceleration (CUDA/OpenCL)
- Prove conjectures about balanced numbers
- Find patterns in strong prime distribution
- Optimize for ARM/RISC-V architectures
MIT License - see LICENSE for details.
- OEIS β Sequence A089395
- Giovanni Resta β numbersaplenty.com validation data
- Rust Community β Excellent libraries (rayon, clap, indicatif)
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: santitub22@gmail.com
If you find this project useful, please consider giving it a β!
Made with β€οΈ and π¦ Rust