LeetCode 172 - Factorial Trailing Zeroes - 题解/Solution

https://leetcode.com/problems/factorial-trailing-zeroes/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
* Given an array of size n, find the majority element. The majority element is
* the element that appears more than n / 2
*
* You may assume that the array is non-empty and the majority element always
* exist in the array.
*
* @author dongyuxi
*
*/
public class Solution {
public int trailingZeroes(int n) {
int zero = 0;
while (n > 0) {
zero += n / 5;
n = n / 5;
}
return zero;
}
}


支付宝 微信
文章目录