18 releases

0.3.7 Jun 7, 2024
0.3.6 Jan 3, 2023
0.3.5 Oct 10, 2022
0.3.2 Feb 16, 2022
0.2.4 Jun 30, 2015

#2136 in Math

Download history 1952/week @ 2024-12-25 4058/week @ 2025-01-01 5101/week @ 2025-01-08 7252/week @ 2025-01-15 6531/week @ 2025-01-22 5849/week @ 2025-01-29 5728/week @ 2025-02-05 5612/week @ 2025-02-12 7504/week @ 2025-02-19 8294/week @ 2025-02-26 6561/week @ 2025-03-05 6141/week @ 2025-03-12 5845/week @ 2025-03-19 4789/week @ 2025-03-26 4222/week @ 2025-04-02 3512/week @ 2025-04-09

19,291 downloads per month
Used in 92 crates (5 directly)

MIT/Apache

560KB
8K SLoC

Highly optimised prime sieves.

This is designed to be used via the primal crate.


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

Dependencies