首页 > 其他 > 详细

172.Factorial Trailing Zeroes

时间:2019-04-12 10:08:59      阅读:96      评论:0      收藏:0      [点我收藏+]
class Solution {
public:
    int trailingZeroes(int n) {
        int res = 0;
        while (n) {
            res += n / 5;
            n /= 5;
        }
        return res;
    }
};
class Solution {
public:
    int trailingZeroes(int n) {
        return n == 0 ? 0 : n / 5 + trailingZeroes(n / 5);
    }
};

172.Factorial Trailing Zeroes

原文:https://www.cnblogs.com/smallredness/p/10694134.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!