Coin de Gamma 1 year ago
parent
commit
9427a9b328
  1. 66
      047/main.rs

66
047/main.rs

@ -0,0 +1,66 @@
use std::collections::HashSet;
type HS = HashSet<u32>;
fn er() -> HS {
let mut nums = Vec::new();
let size = 1_000;
for n in 0..size+1 { nums.push(true); }
let mut p = 1;
loop {
let mut found = false;
for i in p+1..size {
if nums[i] {
found = true;
p = i;
break;
}
}
if !found { break; }
for i in (2 * p .. size).step_by(p) {
nums[i] = false;
}
}
let mut res = HashSet::new();
for i in 2..size {
if nums[i] { res.insert(i as u32); }
}
return res;
}
fn cj(n: u32, ps: &HS) -> u64 {
let mut nn = n;
let mut pc = 0;
for p in ps.iter() {
if nn == 1 {
break;
}
if nn % p == 0 {
pc += 1;
while nn % p == 0 {
nn /= p;
}
}
}
return pc;
}
fn main() {
let ps = er();
for n in 2..10_00000 {
let mut found = true;
for k in 0..=3 {
let t = cj(n + k, &ps);
if t != 4 {
found = false;
break;
}
}
if found {
println!("{}", n);
break;
}
}
}
Loading…
Cancel
Save