# primecount [![Build Status](https://ci.appveyor.com/api/projects/status/github/kimwalisch/primecount?branch=master&svg=true)](https://ci.appveyor.com/project/kimwalisch/primecount) [![Github Releases](https://img.shields.io/github/release/kimwalisch/primecount.svg)](https://github.com/kimwalisch/primecount/releases) primecount is a command-line program and [C/C++ library](doc/libprimecount.md) that counts the primes below an integer x ≤ 1031 using **highly optimized** implementations of the combinatorial [prime counting algorithms](https://en.wikipedia.org/wiki/Prime-counting_function#Algorithms_for_evaluating_%CF%80(x)). primecount includes implementations of all important combinatorial prime counting algorithms known up to this date all of which have been parallelized using [OpenMP](https://en.wikipedia.org/wiki/OpenMP). primecount contains the first ever open source implementations of the Deleglise-Rivat algorithm and Xavier Gourdon's algorithm (that works). primecount also features a [novel load balancer](https://github.com/kimwalisch/primecount/blob/master/src/LoadBalancerS2.cpp) that is shared amongst all implementations and that scales up to hundreds of CPU cores. primecount has already been used to compute several prime counting function [world records](doc/Records.md). ## Installation The primecount command-line program is available in a few package managers. For doing development with libprimecount you may need to install ```libprimecount-dev``` or ```libprimecount-devel```.
Windows: | winget install primecount |
macOS: | brew tap kimwalisch/primecount brew install primecount |
Arch Linux: | sudo pacman -S primecount |
Fedora: | sudo dnf install primecount |
openSUSE: | sudo zypper install primecount |
x | Prime Count | Legendre | Meissel | Lagarias Miller Odlyzko |
Deleglise Rivat |
Gourdon |
1010 | 455,052,511 | 0.01s | 0.01s | 0.01s | 0.01s | 0.00s |
1011 | 4,118,054,813 | 0.01s | 0.01s | 0.01s | 0.01s | 0.01s |
1012 | 37,607,912,018 | 0.03s | 0.02s | 0.02s | 0.01s | 0.01s |
1013 | 346,065,536,839 | 0.09s | 0.06s | 0.03s | 0.02s | 0.03s |
1014 | 3,204,941,750,802 | 0.44s | 0.20s | 0.08s | 0.08s | 0.04s |
1015 | 29,844,570,422,669 | 2.33s | 0.89s | 0.29s | 0.16s | 0.11s |
1016 | 279,238,341,033,925 | 15.49s | 5.10s | 1.26s | 0.58s | 0.38s |
1017 | 2,623,557,157,654,233 | 127.10s | 39.39s | 5.62s | 2.26s | 1.34s |
1018 | 24,739,954,287,740,860 | 1,071.14s | 366.93s | 27.19s | 9.96s | 5.35s |
1019 | 234,057,667,276,344,607 | NaN | NaN | NaN | 40.93s | 20.16s |
1020 | 2,220,819,602,560,918,840 | NaN | NaN | NaN | 167.64s | 81.98s |
1021 | 21,127,269,486,018,731,928 | NaN | NaN | NaN | 706.70s | 353.01s |
1022 | 201,467,286,689,315,906,290 | NaN | NaN | NaN | 3,012.10s | 1,350.47s |
Legendre's Formula | |
Meissel's Formula | |
Lehmer's Formula | |
LMO Formula |
Common Lisp: | cl-primecount |
Julia: | primecount_jll.jl |
Haskell: | hprimecount |
Python: | primecountpy |
Python: | primecount-python |
Rust: | primecount-rs |