init
This commit is contained in:
7
problems/p20/Cargo.toml
Normal file
7
problems/p20/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "p20"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
num-bigint = "0.4.6"
|
||||
17
problems/p20/src/main.rs
Normal file
17
problems/p20/src/main.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use num_bigint::BigUint;
|
||||
|
||||
fn main() {
|
||||
let mut fact = BigUint::from(1u32);
|
||||
for i in 1..=100 {
|
||||
fact *= BigUint::from(i as u32);
|
||||
}
|
||||
let mut sum = BigUint::from(0u32);
|
||||
let ten = BigUint::from(10u32);
|
||||
let zero = BigUint::from(0u32);
|
||||
while fact != zero {
|
||||
sum += &fact % &ten;
|
||||
fact /= &ten;
|
||||
}
|
||||
|
||||
println!("{sum}");
|
||||
}
|
||||
Reference in New Issue
Block a user