题解 | #阶乘末尾0的数量#

阶乘末尾0的数量

http://www.nowcoder.com/practice/aa03dff18376454c9d2e359163bf44b8



public class Solution {
    /**
     * the number of 0
     * @param n long长整型 the number
     * @return long长整型
     */
    public long thenumberof0 (long n) {
        // write code here
        long count = 0;
        long d = 5;
        while(n >= d){
            count+=n/d;
           n = n/d;
        }
        return count;
    }
}

该题就是判断有几个0,阶乘中有多少个10就有多少个0;所以判读一个数有几个5就可以知道。
全部评论

相关推荐

九点快去睡:这个岗位 去年暑假我都见了 现在还在找人 钱是一点没涨
点赞 评论 收藏
分享
03-25 19:00
东北大学 Java
程序员牛肉:太好了,是聊天记录。不得不信了。 当个乐子看就好,不要散播焦虑
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务