use std::fs::File; use std::io::{ self, BufRead, BufReader }; fn get_ps() -> Vec { let file = File::open("primes.txt").unwrap(); let lines = io::BufReader::new(file).lines(); return lines.map(|line| line.unwrap().parse::().unwrap()) .collect(); } fn div_num(ps: &Vec, n: u32) -> u32 { fn max_div(m: u32, k: u32) -> u32 { let mut res = 0; let mut mm = m; while mm % k == 0 { mm /= k; res += 1; } res } let mut res = 1; for p in ps { let md = max_div(n, *p) + 1; res *= md; } return res; } fn main() { let ps = get_ps(); let mut n = 1; let mut best_dn = 1; for k in 2..80000 { n += k; let dn = div_num(&ps, n); if dn > best_dn { best_dn = dn; println!("[{}]{}:{}", k, n, dn); } } }