#prime #number-theory

primal-slowsieve

A simple sieve of Eratosthenes designed for testing faster sieves. You probably want primal-sieve, or even just primal itself.

4 releases

0.3.2 Jun 7, 2024
0.3.1 Aug 15, 2022
0.3.0 Jun 18, 2020
0.2.0 Jun 6, 2015

#23 in #number-theory

Download history 14/week @ 2024-03-02 20/week @ 2024-03-09 10/week @ 2024-03-16 7/week @ 2024-03-23 62/week @ 2024-03-30 11/week @ 2024-04-06 3/week @ 2024-04-13 5/week @ 2024-04-20 6/week @ 2024-04-27 7/week @ 2024-05-04 5/week @ 2024-05-11 9/week @ 2024-05-18 14/week @ 2024-05-25 50/week @ 2024-06-01 134/week @ 2024-06-08 13/week @ 2024-06-15

213 downloads per month
Used in 2 crates

MIT/Apache

54KB
1K SLoC

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:

Sieve small numbers.

This is designed to be used via the primal crate.

Dependencies