What it does

Window analysis using suffixes

microprime_suffix analyses the distribution of prime numbers inside two arbitrary windows placed anywhere on the number line — including heights unreachable by conventional sieves.

The central concept is the suffix: given a window of width W starting at address A, the suffix of a prime p found inside that window is simply p − A. It measures the prime's position relative to the start of the window, independently of where the window sits on the number line.

// suffix example
Window A starts at 10,000 → finds prime 10,069 → suffix = 69
Window B starts at 100,000 → finds prime 100,069 → suffix = 69

10,069 ≠ 100,069 — but both sit at distance 69 from their window's start.
Suffix 69 is shared.
Research context

The gap in the literature

The segmented sieve of Eratosthenes is well-studied up to approximately 10¹⁹ — the int64 limit of tools such as Kim Walisch's primesieve. Beyond that threshold, no public benchmarks exist.

The last published results for high-altitude window sieves date back to Tomás Oliveira e Silva (University of Aveiro, Portugal, ~2010), measured on an Athlon 900 MHz single-thread processor. A systematic literature review published in MDPI Algorithms (April 2024) concluded:

// MDPI Algorithms, April 2024

"The systematic generation of prime numbers has been almost ignored since the 1990s. Sieve techniques are currently used mainly for didactic purposes, and no significant advances have been identified in the last 20 years."

This repository sits precisely in that gap — with original empirical measurements up to 10²⁶ (27 digits) on modern consumer hardware.

Hardware

Test machine

All benchmarks were measured empirically on real hardware — not estimated. Note that this is a mobile laptop processor, not a workstation or server. Reported times are therefore conservative.

CPU
AMD Ryzen 7 4800U
Cores / Threads
8 cores / 16 threads
Base clock
1.80 GHz (boost 4.2)
RAM
32 GB
OS / Compiler
Windows 11 · GCC/MinGW
Flags
-O2 -std=c++20 -fopenmp
Benchmarks

Measured execution times

Times scale with √10 ≈ 3.16 per decade — exactly as predicted by theory for a segmented sieve. The measured data confirms this proportionality with excellent precision. microprime_2 computes one window (W = 10,000,000); microprime_suffix computes two windows (W = 100,000) and takes ~16% longer due to the second window overhead.

Scale Digits GC-60 cycles microprime_2 microprime_suffix
1e19201,273~2 sec2.4 sec
1e20214,023~6 sec7.3 sec
1e212212,717~20 sec24.5 sec
1e222340,212~70 sec86 sec
1e2324127,158~280 sec328 sec
1e2425402,106~1,050 sec1,216 sec
1e25261,271,5674,003 sec (~67 min)4,635 sec (~77 min)
1e26274,021,04517,600 sec (~4.9 h)~20,300 sec (~5.6 h)
Output example

Analysis charts

For each experiment, the Python script analisi_suffix.py generates a six-panel chart from the CSV output. Below is a real example comparing two windows at prefix 10¹⁶ with W = 510,502.

Six-panel suffix analysis chart: timeline, density by thirds, gap per position, gap distribution, last digit, gap mod q
prefix 10000000000000001021020 vs 10000000000000001531530 — W = 510,502 · Solo A: 9,488 primes · Solo B: 9,185 primes · Common suffixes: 1,173

Each chart contains six panels:

Panel 1
Suffix timeline
Spatial distribution of primes in both windows, with common suffixes highlighted.
Panel 2
Density by thirds
How many primes fall in the first, second, and third third of each window.
Panel 3
Gap per position
s_B[i] − s_A[i]: the "race" between the two windows, moment by moment.
Panel 4
Gap distribution
Statistical snapshot of the entire race between the two windows.
Panel 5
Last digit
Verification of Dirichlet's theorem — expected 25% each for digits 1, 3, 7, 9.
Panel 6
Gap mod q
The modular signature of W — an invariant that depends only on window width, not on scale.
Key findings

Three observed behaviours

Comparing two windows A and B of width W, suffix analysis reveals three distinct patterns in the gap curve (s_B[i] − s_A[i]):

Behaviour 1
Negative ramp
With adjacent windows (distance = W) at scale ~1e17, the gap starts near zero and progressively drops to ~−5,000, then partially recovers. Window B accumulates a systematic lead.
Behaviour 2
Symmetric oscillation
At scale ~2.5e18 with the same conditions, the gap oscillates around zero with no systematic trend. The two windows alternate without either prevailing.
Behaviour 3 · invariant
Modular signature of W
For each small prime q, the dominant residue of gap(i) mod q equals (−W) mod q. This property is scale-invariant: identical at 1e14 and at 1e21. It depends only on W.
Usage

How to run it

01

Create the output folder

The program writes results to a fixed path on Windows.

mkdir C:\dati_suffix\
02

Edit dati_di_ricerca.txt

Define your experiments. Supports 10^N, 2^N, and arbitrary integers up to 10³⁸ (__int128).

# format: A, B, W
10^20, 10^21, 100000
2^63, 2^64, 100000
7652376576523765, 9652376576523765, 100000
03

Run microprime_suffix.exe

Results are written to C:\dati_suffix\suffix_data_N.csv — one file per experiment, numbered in order.

04

Run analisi_suffix.py

PNG charts are generated automatically for every CSV found in the output folder. No arguments needed.

python analisi_suffix.py
Resources

Download and documentation

Source code, precompiled executable, and technical guide are available on GitHub and archived on Zenodo.