#prime #number-theory

primal-bit

Bit-vector specialised to the prime-number-related needs of primal

8 releases

0.3.2 Jun 7, 2024
0.3.1 Aug 15, 2022
0.3.0 Jun 18, 2020
0.2.4 Aug 22, 2017
0.2.2 Jun 9, 2015

#1956 in Math

Download history 3698/week @ 2024-07-23 5365/week @ 2024-07-30 3193/week @ 2024-08-06 4354/week @ 2024-08-13 3812/week @ 2024-08-20 4263/week @ 2024-08-27 4410/week @ 2024-09-03 4017/week @ 2024-09-10 4156/week @ 2024-09-17 3908/week @ 2024-09-24 4283/week @ 2024-10-01 4488/week @ 2024-10-08 8277/week @ 2024-10-15 6096/week @ 2024-10-22 6568/week @ 2024-10-29 5484/week @ 2024-11-05

27,227 downloads per month
Used in 83 crates (2 directly)

MIT/Apache

19KB
478 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:

A very simple bit-vector that serves the needs of primal.

Dependencies

~18KB