[leetcode]Factorial Trailing Zeroes

时间:2015-01-01 00:08:39   收藏:0   阅读:270

老题,简单题。数5的个数就行了。

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

  

原文:http://www.cnblogs.com/lautsie/p/4196761.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!