fn ds(n: u32) -> Vec { let mut res = Vec::new(); let mut a = n; while a > 0 { res.push(a % 10); a/=10; } res } fn fc(n: u32) -> u32 { if n == 0 { return 1; } return n * fc(n-1); } fn test(n: u32) -> bool { let d = ds(n); let mut sum = 0; for k in d { sum += fc(k); } return n == sum; } fn main() { let mut sum = 0; for n in 3..10_000_000 { if test(n) { println!("{}", n); sum += n } } println!("sum: {}", sum); }