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() { + } +}