You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.3 KiB

11 months ago
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;
}
}
}