每天一道LeetCode--172. Factorial Trailing Zeroes

Posted 华裳绕指柔

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了每天一道LeetCode--172. Factorial Trailing Zeroes相关的知识,希望对你有一定的参考价值。

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

Note: Your solution should be in logarithmic time complexity.

 此题是求阶乘后面零的个数。

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

 

以上是关于每天一道LeetCode--172. Factorial Trailing Zeroes的主要内容,如果未能解决你的问题,请参考以下文章

Factor

leetcode172

LeetCode----172. Factorial Trailing Zeroes(Java)

LeetCode172 Factorial Trailing Zeroes. LeetCode258 Add Digits. LeetCode268 Missing Number

Leetcode 172. Factorial Trailing Zeroes

LeetCode 172. 阶乘后的零(Factorial Trailing Zeroes)