Pythagorean Modular Prime Sieve – C++ Reference Implementation
Authors/Creators
Description
C++ reference implementation of the Pythagorean modular prime sieve operating on the inradius index r, with optional OpenMP parallelism and batch or pure streaming APIs. The software is designed for memory-efficient prime generation and direct access to distant prime ranges.
This repository provides an industrial-grade C++ implementation of the **Pythagorean modular prime sieve**, a novel prime generation method introduced by Roberto Amato.
The algorithm is based on a modular reformulation of divisibility arising from Pythagorean geometry. Odd integers are parametrized as
$$
x = 2r + 1,
$$
and composite values are excluded through a single congruence condition on the index $r$. For any odd divisor $d \geq 3$, one has
$$
x \text{ divisible by } d
\;\Longleftrightarrow\;
r \equiv \frac{d - 1}{2} \pmod{d}.
$$
Each odd divisor eliminates exactly one residue class modulo $d$, yielding a sparse modular sieve with reduced memory requirements.
This formulation naturally supports segmentation, parallel execution, and streaming prime generation, and enables direct access to primes located far from the origin without storing all preceding values.
Notes
Files
Additional details
Related works
- Is part of
- Software: https://github.com/Pythagorean-Sieve/pythagorean-sieve-cpp (URL)
Software
- Repository URL
- https://github.com/Pythagorean-Sieve/pythagorean-sieve-cpp