Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit514a64d

Browse files
refactor 172
1 parentf77624b commit514a64d

File tree

1 file changed

+23
-26
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+23
-26
lines changed
Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
11
packagecom.fishercoder.solutions;
2+
23
/**
34
* 172. Factorial Trailing Zeroes
4-
5-
Given an integer n, return the number of trailing zeroes in n!.
6-
7-
Example 1:
8-
9-
Input: 3
10-
Output: 0
11-
Explanation: 3! = 6, no trailing zero.
12-
13-
Example 2:
14-
15-
Input: 5
16-
Output: 1
17-
Explanation: 5! = 120, one trailing zero.
18-
19-
Note: Your solution should be in logarithmic time complexity.
20-
5+
*
6+
* Given an integer n, return the number of trailing zeroes in n!.
7+
*
8+
* Example 1:
9+
* Input: 3
10+
* Output: 0
11+
* Explanation: 3! = 6, no trailing zero.
12+
*
13+
* Example 2:
14+
* Input: 5
15+
* Output: 1
16+
* Explanation: 5! = 120, one trailing zero.
17+
* Note: Your solution should be in logarithmic time complexity.
2118
*/
2219
publicclass_172 {
2320

24-
publicstaticclassSolution1 {
25-
publicinttrailingZeroes(intn) {
26-
intresult =0;
27-
while (n >4) {
28-
n /=5;
29-
result +=n;
30-
}
31-
returnresult;
21+
publicstaticclassSolution1 {
22+
publicinttrailingZeroes(intn) {
23+
intresult =0;
24+
while (n >4) {
25+
n /=5;
26+
result +=n;
27+
}
28+
returnresult;
29+
}
3230
}
33-
}
3431
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp