Math 172. Factorial Trailing Zeroes¶ Time: O(log5n)O(\log_5 n)O(log5n) Space: O(1)O(1)O(1) C++JavaPython 1 2 3 4 5 6class Solution { public: int trailingZeroes(int n) { return n == 0 ? 0 : n / 5 + trailingZeroes(n / 5); } }; 1 2 3 4 5class Solution { public int trailingZeroes(int n) { return n == 0 ? 0 : n / 5 + trailingZeroes(n / 5); } } 1 2 3class Solution: def trailingZeroes(self, n: int) -> int: return 0 if n == 0 else n // 5 + self.trailingZeroes(n // 5) Was this page helpful? Thanks for your feedback! Thanks for your feedback! Help us improve this page by using our feedback form.