172. Factorial Trailing Zeroes Medium
1/**
2 * [172] Factorial Trailing Zeroes
3 *
4 * Given an integer n, return the number of trailing zeroes in n!.
5 * Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1.
6 *
7 * Example 1:
8 *
9 * Input: n = 3
10 * Output: 0
11 * Explanation: 3! = 6, no trailing zero.
12 *
13 * Example 2:
14 *
15 * Input: n = 5
16 * Output: 1
17 * Explanation: 5! = 120, one trailing zero.
18 *
19 * Example 3:
20 *
21 * Input: n = 0
22 * Output: 0
23 *
24 *
25 * Constraints:
26 *
27 * 0 <= n <= 10^4
28 *
29 *
30 * Follow up: Could you write a solution that works in logarithmic time complexity?
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/factorial-trailing-zeroes/
36// discuss: https://leetcode.com/problems/factorial-trailing-zeroes/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41 pub fn trailing_zeroes(n: i32) -> i32 {
42 0
43 }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_172() {
54 }
55}
56
Back
© 2025 bowen.ge All Rights Reserved.