# [172\. Factorial Trailing Zeroes](https://leetcode.com/problems/factorial-trailing-zeroes/) 找階層 $n!$ 的尾端有多少個 `0`,也就是找 `10` 的個數,但因為 `2` 太多了,所以找有多少個 `5` 就好 :::spoiler Solution ```cpp= class Solution { public: int trailingZeroes(int n) { int res = 0; while (n) { res += n / 5; n /= 5; } return res; } }; ``` - 時間複雜度:$O(n)$ - 空間複雜度:$O(1)$ :::