Loading...
Searching...
No Matches
primesieve

# About

primesieve is a C/C++ library for quickly generating prime numbers. It generates the primes below 10^9 in just 0.2 seconds on a single core of an Intel Core i7-6700 3.4GHz CPU from 2015. primesieve can generate primes and prime k-tuplets up to 2^64. primesieve's memory requirement is about pi(sqrt(n)) * 8 bytes per thread, its run-time complexity is O(n log log n) operations. The recommended way to get started is to first have a look at a few C or C++ example programs. The most common use cases are iterating over primes using next_prime() or prev_prime() and storing primes in a vector or an array.

For more information please visit https://github.com/kimwalisch/primesieve.

# Installation

- Install libprimesieve using package manager.
- Build libprimesieve from source.

# C API

- primesieve.h - primesieve C header.
- primesieve_iterator - Provides the primesieve_next_prime() and primesieve_prev_prime() functions.
- C examples - Example programs that show how to use libprimesieve.
- C error handling - How to detect and handle errors.
- Link against libprimesieve.

# C++ API

- primesieve.hpp - primesieve C++ header.
- primesieve::iterator - Provides the next_prime() and prev_prime() methods.
- C++ examples - Example programs that show how to use libprimesieve.
- C++ error handling - How to detect and handle errors.
- Link against libprimesieve.

# Performance tips

- libprimesieve performance tips
- Multi-threading
- SIMD (vectorization)