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.

35 lines
551 B

fn ds(n: u32) -> Vec<u32> {
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);
}