const NUMS_LEN: usize = 28124; fn is_abundant(n: usize) -> bool { let mut s = 0; for i in 1..n { if n % i == 0 { s += i; } } return s > n; } fn main() { //let r = is_abundant(12); let mut ambs = Vec::::new(); for i in 1..NUMS_LEN { if is_abundant(i) { ambs.push(i); } } let mut candidates: [bool; NUMS_LEN] = [false; NUMS_LEN]; for a in &ambs { //println!("a: {}", a); for b in &ambs { if a + b < NUMS_LEN { candidates[a + b] = true; } } } let mut res_sum = 0usize; for i in 0..NUMS_LEN { if !candidates[i] { res_sum += i; } } println!("result: {}", res_sum); //println!("is abundant: {}", r); }