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

Commitc05a6f1

Browse files
author
applewjg
committed
Factorial Trailing Zeroes
Change-Id: I876626a1bc512ea53fd09c274f22d010cdc73371
1 parent0618f12 commitc05a6f1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎FactorialTrailingZeroes.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Author: King, wangjingui@outlook.com
3+
Date: Dec 13, 2014
4+
Problem: Factorial Trailing Zeroes
5+
Difficulty: Easy
6+
Source: https://oj.leetcode.com/problems/factorial-trailing-zeroes/
7+
Notes:
8+
Given an integer n, return the number of trailing zeroes in n!.
9+
10+
Note: Your solution should be in logarithmic time complexity.
11+
12+
Solution: ...
13+
*/
14+
publicclassSolution {
15+
publicinttrailingZeroes(intn) {
16+
intres =0;
17+
while (n !=0) {
18+
res +=n /5;
19+
n =n /5;
20+
}
21+
returnres;
22+
}
23+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp