Prime numbers distribution

How to download and unpack the TeraPrimes files.

Single segments covering 446,185,740 integers can be retrieved individually. We also provide ZIP files containing 100 segments.

You can use our python code to unpack the data.

All files are freely available. Please mention TeraPrimes.org if you use them.

Download single segments

The first segment (segment 0) does NOT contain the prime numbers 2, 3, 5, 7, 11, 13, 17, 19 or 23.

Loading available segments…

Download ZIP files

From the following table, you can download all validated segments grouped in ZIP files. Each file groups up to 100 independently validated segments.

The first segment of the first file does NOT contain the prime numbers 2, 3, 5, 7, 11, 13, 17, 19 or 23.

File Segments Start (M) End (M) Primes ZIP size ZIP SHA-256 Action
Loading catalogue data...

Python code to convert a segment to text

The standalone Python 3 script reads version 4 .bin.gz files containing a directly gzipped raw bitmap, as well as uncompressed raw bitmaps. It writes one represented prime per line and requires no third-party package.

Download the Python converter

python3 primefiles-to-text.py primefiles-000001-446185740-892371480-coprime23-v4.bin.gz

# If the file was renamed, give its physical bitmap start:
python3 primefiles-to-text.py segment.bin.gz primes.txt --start 446185740

# Optionally include the nine implicit primes when converting segment 0:
python3 primefiles-to-text.py primefiles-000000-24-446185740-coprime23-v4.bin.gz \
  --include-implicit-small-primes

Keep the original public filename when possible: the script can then infer the range automatically, including the special physical alignment of segment 0.