Description
primesieve is a command-line program and C/C++ library for generating prime numbers very quickly. It uses the segmented sieve of Eratosthenes with wheel factorization, which runs in O(n log log n) operations and O(sqrt n) memory, plus a bucket sieve that improves cache efficiency for primes above 2^32. It detects your CPU's L1 and L2 cache sizes to size its data structures, and uses all CPU cores by default when results don't need to be in order. It can generate primes and prime k-tuplets up to 2^64. Printing primes or writing them to a text file runs single-threaded, so the library is the faster route for in-memory generation. The program also includes CPU and memory stress testing. It is available through package managers including winget, Homebrew, apt, dnf, pacman, zypper and FreeBSD pkg.…
Highlights
- Segmented sieve of Eratosthenes with wheel factorization
- Cache-aware and multi-threaded
- Primes and prime k-tuplets up to 2^64
- Command-line tool and C/C++ library
- CPU and memory stress testing
- Packages for Windows, macOS, Linux and FreeBSD
Ratings & Reviews
No ratings yet
Be the first to rate Primesieve.
People also visit

tilegym-improve-cutile-kernel-perf
Iteratively optimize cuTile kernel performance through systematic profiling
trailofbits/constant-time-analysis
Detect compiler-induced timing side-channels in crypto code

benchmark-optimization-loop
Convert 'make it faster' requests into a bounded measured optimization loop
Primesieve FAQ
How do I install primesieve?
Use your package manager: winget install primesieve on Windows, brew install primesieve on macOS, sudo apt install primesieve on Debian/Ubuntu, sudo dnf install primesieve on Fedora, sudo pacman -S primesieve on Arch, pkg install primesieve on FreeBSD or sudo zypper install primesieve on openSUSE.
How large can the primes be?
It generates primes and prime k-tuplets up to 2^64.
Why is printing primes slower than counting them?
Printing and writing to files run single-threaded because they need sequential order. For maximum throughput, generate primes in memory with libprimesieve.
What algorithm does it use?
A segmented sieve of Eratosthenes with wheel factorization, plus a bucket sieve for primes above 2^32. Memory use is about 8 bytes per sieving prime per thread.
Can it stress test my computer?
Yes. It includes stress testing modes for both the CPU and memory.
What are the best Primesieve alternatives?
Popular alternatives to Primesieve include PARI/GP. See all Primesieve alternatives








