###### fantasia的博客

Somewhere on this planet

### 172. Factorial Trailing Zeroes

Total Accepted: 60237 Total Submissions: 182176 Difficulty: Easy

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

Note: Your solution should be in logarithmic time complexity.

0由2,5相乘得出。5的个数一定小于2。所以只用判断5的个数。需要注意的是5,10,15,20都只提供一个5，但是25提供了两个5！

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

#### leetcode 172: Factorial Trailing Zeroes

2014-12-30 09:54:52

#### 【LeetCode-面试算法经典-Java实现】【172-Factorial Trailing Zeroes（阶乘尾后0的数目）】

2015-08-23 06:43:47

#### 172. Factorial Trailing Zeroes [easy] (Python)

2016-06-05 17:40:21

#### LeetCode(172) Factorial Trailing Zeroes

2015-01-02 03:46:08

#### Leetcode: Factorial Trailing Zeroes

2015-01-02 21:23:32

#### 172 Factorial Trailing Zeroes 过了。英文真不好读啊。

2014-12-30 18:52:33

#### 【LeetCode】Factorial Trailing Zeroes 阶乘尾部0的个数

2015-04-23 15:53:00

#### LeetCode：求阶乘后面的0的个数（Factorial Trailing Zeroes）

2016-04-03 15:54:48

#### LeetCode Factorial Trailing Zeroes数学方法详解

2016-08-05 15:14:24

#### LeetCode -- Factorial Trailing Zeroes

2015-10-04 16:19:37

## 不良信息举报

Leetcode 172. Factorial Trailing Zeroes