Factorial Trailing Zeroes

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

Note: Your solution should be in logarithmic time complexity.

//求阶乘后面0的个数,可以通过判断此数是零的多好倍数

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


你可能感兴趣的:(leetcode)