ゼロ階乗後LeetCode。

トピックス要件:

整数nが与えられ、結果の仮数部におけるゼロのn個!数を返します。

例:

入力:3
出力:0
説明:! 3 = 6、仮数がゼロではありません。

ソリューション:

class Solution {
public:
    int trailingZeroes(int n) {
        int result = 0;
        while(n) {
            n /= 5;
            result += n;
        }
        return result;
    }
};

おすすめ

転載: www.cnblogs.com/leyang2019/p/11696107.html