File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 164
164
168|[ Excel Sheet Column Title] ( ./0168-excel-sheet-column-title.js ) |Easy|
165
165
169|[ Majority Element] ( ./0169-majority-element.js ) |Easy|
166
166
171|[ Excel Sheet Column Number] ( ./0171-excel-sheet-column-number.js ) |Easy|
167
+ 172|[ Factorial Trailing Zeroes] ( ./0172-factorial-trailing-zeroes.js ) |Medium|
167
168
173|[ Binary Search Tree Iterator] ( ./0173-binary-search-tree-iterator.js ) |Medium|
168
169
179|[ Largest Number] ( ./0179-largest-number.js ) |Medium|
169
170
187|[ Repeated DNA Sequences] ( ./0187-repeated-dna-sequences.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 172. Factorial Trailing Zeroes
3
+ * https://leetcode.com/problems/factorial-trailing-zeroes/
4
+ * Difficulty: Medium
5
+ *
6
+ * Given an integer n, return the number of trailing zeroes in n!.
7
+ *
8
+ * Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1.
9
+ */
10
+
11
+ /**
12
+ * @param {number } n
13
+ * @return {number }
14
+ */
15
+ var trailingZeroes = function ( n ) {
16
+ return n < 5 ? 0 : Math . floor ( n / 5 ) + trailingZeroes ( n / 5 ) ;
17
+ } ;
You can’t perform that action at this time.
0 commit comments