Coin de Gamma
2 years ago
2 changed files with 35 additions and 0 deletions
Binary file not shown.
@ -0,0 +1,35 @@ |
|||||||
|
const SIZE: usize = 1500000; // found this with manual binary search, it's legal! :)
|
||||||
|
type Rs = [bool; SIZE + 1]; |
||||||
|
|
||||||
|
fn remove_divs(m: usize, xs: &mut Rs) { |
||||||
|
let mut i = m + m; |
||||||
|
while i <= SIZE { |
||||||
|
xs[i] = false; |
||||||
|
i += m; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fn get_next_p(m_from: usize, xs: &Rs) -> Option<usize> { |
||||||
|
for k in (m_from + 1)..=SIZE { |
||||||
|
if xs[k] { return Some(k); }
|
||||||
|
} |
||||||
|
return None; |
||||||
|
} |
||||||
|
|
||||||
|
fn main() { |
||||||
|
let mut xs: Rs = [true; SIZE + 1]; |
||||||
|
let mut q: usize = 1; |
||||||
|
let mut count = 0; |
||||||
|
loop { |
||||||
|
match get_next_p(q, &xs) { |
||||||
|
Some(p) => {
|
||||||
|
q = p;
|
||||||
|
count += 1; |
||||||
|
if count == 10_001 { break; } |
||||||
|
},
|
||||||
|
None => break
|
||||||
|
} |
||||||
|
remove_divs(q, &mut xs); |
||||||
|
} |
||||||
|
println!("[{}]: {}", count, q); |
||||||
|
} |
Loading…
Reference in new issue