#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).

5 releases

0.2.3 Jun 8, 2015
0.2.2 Jun 8, 2015
0.2.1 Jun 7, 2015
0.2.0 Jun 6, 2015
0.1.14 May 16, 2015

#58 in Math

Download history 209/week @ 2019-08-01 251/week @ 2019-08-08 360/week @ 2019-08-15 413/week @ 2019-08-22 464/week @ 2019-08-29 674/week @ 2019-09-05 454/week @ 2019-09-12 368/week @ 2019-09-19 281/week @ 2019-09-26 295/week @ 2019-10-03 266/week @ 2019-10-10 289/week @ 2019-10-17 353/week @ 2019-10-24 302/week @ 2019-10-31 603/week @ 2019-11-07

2,491 downloads per month
Used in 17 crates (13 directly)

MIT/Apache

500KB
7.5K SLoC

Standard ML (SML) 7K SLoC // 0.1% comments Rust 227 SLoC // 0.3% comments

primal

Build Status Coverage Status 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

~300KB