Coin de Gamma
1 year ago
1 changed files with 35 additions and 0 deletions
@ -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…
Reference in new issue