糖醋里脊

有召唤,爱自由.
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

trailingZeroes

Posted on 2015-09-03 09:01  糖醋里脊er  阅读(138)  评论(0)    收藏  举报

Given an integer n, return the number of trailing zeroes in n!.

给一个数字n,返回它n!数字后面有多少个0。

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