Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
28 lines (25 loc) · 586 Bytes

File metadata and controls

28 lines (25 loc) · 586 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.lintcode;
/**
* 2. 尾部的零
* 设计一个算法,计算出n阶乘中尾部零的个数
*
* 样例
11! = 39916800,因此应该返回 2
*
* O(logN)的时间复杂度
*/
public class Solution2 {
/*
* @param n: An integer
* @return: An integer, denote the number of trailing zeros in n!
*/
public long trailingZeros(long n) {
// write your code here, try to do it without arithmetic operators.
long count = 0;
while (n > 0){
count += n / 5;
n /= 5;
}
return count;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.