#prime #number-theory #lower-bounds

primal-estimate

State-of-the-art estimation of upper and lower bounds for π(n) (the number of primes below n) and p_k (the k-th prime)

6 releases

0.3.3 Jun 7, 2024
0.3.2 Aug 15, 2022
0.3.1 Jun 18, 2020
0.2.1 Jun 8, 2015

#1728 in Math

Download history 4053/week @ 2024-03-04 4137/week @ 2024-03-11 3378/week @ 2024-03-18 2607/week @ 2024-03-25 3125/week @ 2024-04-01 2237/week @ 2024-04-08 3214/week @ 2024-04-15 4145/week @ 2024-04-22 5074/week @ 2024-04-29 4239/week @ 2024-05-06 3341/week @ 2024-05-13 2517/week @ 2024-05-20 2713/week @ 2024-05-27 3932/week @ 2024-06-03 6592/week @ 2024-06-10 4932/week @ 2024-06-17

18,299 downloads per month
Used in 78 crates (3 directly)

MIT/Apache

21KB
251 lines

primal

crates.io documentation minimum rustc 1.36

primal puts raw power into prime numbers.

This crates includes

  • optimised prime sieves
  • checking for primality
  • enumerating primes
  • factorising numbers
  • estimating upper and lower bounds for π(n) (the number of primes below n) and pk (the kth prime)

This uses a state-of-the-art cache-friendly Sieve of Eratosthenes to enumerate the primes up to some fixed bound (in a memory efficient manner), and then allows this cached information to be used for things like enumerating and counting primes.

primal takes around 2.8 seconds and less than 3MB of RAM to count the exact number of primes below 1010 (455052511) on the author's laptop (i7-3517U).

Documentation


lib.rs:

Estimate upper and lower bounds for the n-th prime, and π(n), the number of primes less than or equal to n.

This is designed to be used via the primal crate.

No runtime deps