File tree 1 file changed +23
-26
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +23
-26
lines changed Original file line number Diff line number Diff line change 1
1
package com .fishercoder .solutions ;
2
+
2
3
/**
3
4
* 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.
21
18
*/
22
19
public class _172 {
23
20
24
- public static class Solution1 {
25
- public int trailingZeroes (int n ) {
26
- int result = 0 ;
27
- while (n > 4 ) {
28
- n /= 5 ;
29
- result += n ;
30
- }
31
- return result ;
21
+ public static class Solution1 {
22
+ public int trailingZeroes (int n ) {
23
+ int result = 0 ;
24
+ while (n > 4 ) {
25
+ n /= 5 ;
26
+ result += n ;
27
+ }
28
+ return result ;
29
+ }
32
30
}
33
- }
34
31
}
You can’t perform that action at this time.
0 commit comments