Created
February 2, 2020 03:39
-
-
Save scratchyone/c43486b0a8377e4f3af2cb221d1cccbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn prime(amount: i32) -> Vec<i64> { | |
let amount: usize = amount as usize; | |
let mut out: Vec<usize> = (0..amount).collect::<Vec<usize>>(); | |
for x in 2..amount { | |
for i in (x * x..amount).step_by(x) { | |
out[i] = 0; | |
} | |
if out[x] == 0 { | |
continue; | |
} | |
} | |
return out | |
.into_iter() | |
.filter(|n| *n != 0) | |
.map(|n| n as i64) | |
.collect::<Vec<i64>>(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment