solutions: 20

This commit is contained in:
Muhammad Nauman Raza 2024-12-04 10:41:04 +00:00
parent f0858b63e6
commit e058da0bd4
Signed by: devraza
GPG key ID: 91EAD6081011574B

View file

@ -0,0 +1,19 @@
use num_bigint::BigUint;
fn factorial(x: u64) -> BigUint {
let mut product = BigUint::from(1 as u64);
for i in 2..=x {
product *= BigUint::from(i);
}
product.into()
}
fn main() {
let number = factorial(100);
let mut digits: Vec<u64> = vec![];
for i in number.to_string().chars().filter_map(|c| c.to_digit(10)) {
digits.push(i as u64);
}
println!("{}", digits.iter().sum::<u64>());
}