From dc662fe1562750d896ade46ef318923b746a39ae Mon Sep 17 00:00:00 2001 From: jackfiled Date: Wed, 31 Jul 2024 10:54:14 +0800 Subject: [PATCH] 20240731 Finished --- src/problem/mod.rs | 3 +- src/problem/p172_factorial_trailing_zeroes.rs | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/problem/p172_factorial_trailing_zeroes.rs diff --git a/src/problem/mod.rs b/src/problem/mod.rs index 86cf501..4272816 100644 --- a/src/problem/mod.rs +++ b/src/problem/mod.rs @@ -189,4 +189,5 @@ mod p191_number_of_1_bits; mod p136_single_number; mod p137_single_number_ii; mod p201_bitwise_and_of_numbers_range; -mod p66_plus_one; \ No newline at end of file +mod p66_plus_one; +mod p172_factorial_trailing_zeroes; \ No newline at end of file diff --git a/src/problem/p172_factorial_trailing_zeroes.rs b/src/problem/p172_factorial_trailing_zeroes.rs new file mode 100644 index 0000000..8adb62d --- /dev/null +++ b/src/problem/p172_factorial_trailing_zeroes.rs @@ -0,0 +1,32 @@ +/** + * [172] Factorial Trailing Zeroes + */ +pub struct Solution {} + + +// submission codes start here + +impl Solution { + pub fn trailing_zeroes(n: i32) -> i32 { + let mut n = n; + let mut result = 0; + + while n > 0 { + n /= 5; + result += n; + } + + result + } +} + +// submission codes end + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_172() { + } +}