#math #mathematics #primes #number-theory

primal

primal puts raw power into prime numbers. This crates includes: optimised prime sieves, checking for primality, enumerating primes, factorising numbers, and 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

✓ Uses Rust 2018 edition

0.3.0 Jun 18, 2020
0.2.3 Jun 8, 2015
0.1.14 May 16, 2015

#59 in Math

Download history 482/week @ 2020-03-16 512/week @ 2020-03-23 501/week @ 2020-03-30 725/week @ 2020-04-06 639/week @ 2020-04-13 511/week @ 2020-04-20 799/week @ 2020-04-27 517/week @ 2020-05-04 508/week @ 2020-05-11 427/week @ 2020-05-18 296/week @ 2020-05-25 592/week @ 2020-06-01 482/week @ 2020-06-08 656/week @ 2020-06-15 536/week @ 2020-06-22 460/week @ 2020-06-29

2,326 downloads per month
Used in 23 crates (17 directly)

MIT/Apache

510KB
7.5K SLoC

primal

Build Status codecov crates.io

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

~305KB