Browse Source

007 ok

master
Coin de Gamma 2 years ago
parent
commit
fbcc20a62b
  1. BIN
      007/main
  2. 35
      007/main.rs

BIN
007/main

Binary file not shown.

35
007/main.rs

@ -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…
Cancel
Save