Sha256: 9b0e678aefd3dc196826631d3024024c288758ca14b0a48cca5fc894cc42ab2e

Contents?: true

Size: 308 Bytes

Versions: 396

Compression:

Stored size: 308 Bytes

Contents

pub fn primes_up_to(limit: i32) -> Vec<i32> {
    let mut integers = (1..limit).map(|x| x + 1).collect::<Vec<i32>>();
    let mut p = Some(2);

    while let Some(y) = p {
        integers.retain(|&x| (x == y) || (x % y != 0));
        p = integers.clone().into_iter().find(|x| *x > y);
    }
    integers
}

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.179 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.178 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.177 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.176 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.175 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.174 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.173 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.172 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.171 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.170 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.169 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.167 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.166 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.165 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.164 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.163 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.162 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.161 tracks/rust/exercises/sieve/example.rs
trackler-2.2.1.160 tracks/rust/exercises/sieve/example.rs