#prime #math #algorithm

primes

A package for calculating primes using the Sieve of Eratosthenes, and using that to check if a number is prime and calculating factors. Includes an iterator over all primes.

15 releases

0.4.0 Jun 7, 2024
0.3.0 Mar 8, 2020
0.2.4 Dec 26, 2019
0.2.3 Aug 29, 2018
0.1.0 Nov 26, 2014

#251 in Algorithms

Download history 2481/week @ 2024-12-14 1088/week @ 2024-12-21 1463/week @ 2024-12-28 2084/week @ 2025-01-04 2004/week @ 2025-01-11 2295/week @ 2025-01-18 1905/week @ 2025-01-25 1699/week @ 2025-02-01 2095/week @ 2025-02-08 1714/week @ 2025-02-15 2090/week @ 2025-02-22 1867/week @ 2025-03-01 1189/week @ 2025-03-08 1987/week @ 2025-03-15 1534/week @ 2025-03-22 1027/week @ 2025-03-29

5,991 downloads per month
Used in 20 crates (14 directly)

BSD-3-Clause

15KB
303 lines

primes

Build Status Build Status

A prime generator for Rust.

This package is available on crates.io as primes.

This package provides an iterator over all primes, generating them lazily as it goes.

The simplest usage is simply to create an Iterator:

use primes::PrimeSet;

let mut pset = PrimeSet::new();

for (ix, n) in pset.iter().enumerate().take(10) {
    println!("Prime {}: {}", ix, n);
}

For more examples, see the full documentation!

No runtime deps