lazy-prime-sieve

Lazy Sieve of Eratosthenes for infinitely generating primes lazily in Rust.

Usage

lazy-prime-sieve is a library crate. You may add it to your Cargo.toml as follows:

toml [dependencies] lazy-prime-sieve = "0.1.1"

lazy-prime-sieve provides iterators for infinitely generating primes. This crate provides a convenience method ::primes() which returns the most efficient iterator (in this crate) for generating primes.

```rust use lazyprimesieve::primes;

for i in primes().take(10) { println!("{i}"); } ```

Benchmarks

prime-sieves-bench

This benchmark shows the time taken by the different prime generating iterators in this crate to generate a certain number of primes. The x-axis shows the number of primes generated, while the y-axis shows the amount of time taken.

References

This crate heavily draws from the paper The Genuine Sieve of Eratosthenes. This repository attempts to provide non-recursive lazy Rust iterator based alternatives to the Haskell lazy list + recursion based methods proposed in the paper.

License

lazy-prime-sieve is licensed under the MIT License. See License for more details.