Browse Source

034 ok

master
Coin de Gamma 11 months ago
parent
commit
fc50226939
  1. 35
      034/main.rs

35
034/main.rs

@ -0,0 +1,35 @@
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);
}
Loading…
Cancel
Save